English 中文(简体)
a. 可通过变数提一栏
原标题:vb referencing a column via a variable

I am trying to update an Access database with a vb script by putting a soccer scoreline into a column dependent on when a goal is scored.

因此,我有一个表格,有一栏。

matchID 1 2 3 4.... 89 90

我写了这封信。

Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblScoreLinesByMinute", dbOpenTable)

Let us say there was a goal scored by the home team in the 3rd minute I have captured this with a variable numTime = 3 and created a variable strScoreline = 10. I wish to update the table something like

rst![numTime] = strScoreline

但是,如果我尝试这一或“CStr(numtime),则我会遇到一个错误,即“本收集中没有发现的情况”。 硬编码

rst![3] =strScoreline 工作

我也渴望将其他各栏划入相关的记分线。 让我们说,离队在88分钟平等。 下面,我所看到的是这一特殊匹配的行文,显示0栏1 2、3栏至87栏、10栏88-90 11

如果有更简单的方法,我也可以使用ms。

最佳回答

如果我正确理解你问题的第一部分,我认为你应努力:

rst.Fields(numTime) = strScoreline

I have no clue about the second part of your question.

Edit: Your comment made me think your numTime text values were being interpreted as numbers rather than string values by rst.Fields. However, that doesn t appear to be the case here.

依据同一表格和外地名称开立记录单,这部法规有一处错误(“本收集中未发现的”):

numTime = "0"
Debug.Print rst.Fields(numTime)

但是,这部法典印刷了“2”栏的价值:

numTime = "2"
Debug.Print rst.Fields(numTime)

因此,我仍然不理解为什么不为你工作。 但我从未使用过编号作为栏目;在我看来这是错误的。 如果你把你的栏目改名为MatchID、f1、f2、f3,而且这种做法仍然不奏效,我会感到更加惊讶。

问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签