A
Anita Mossey
I have inherited a project that uses some DAO. I only
know the newer ADO code. I have copied parts of the DAO
code.
The form's record source is tblSwitchboardItems. A
composite key consists of the SwitchboardID and
ItemNumber fields. Both fields are of the number data
type.
On the statement just before End Sub, I get the message
box error, "Run-time error '13'; Type mismatch."
On the statement just before End Function,
![SwitchboardID] gets highlighted in blue and I get the
message box error, "Compile error: Method or data member
not found." This is in spite of the fact that the table
has a field named SwitchboardID.
Any ideas as to how to rectify these errors? Thanks much
in advance.
Private Sub FillOptions()
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [tblSwitchboardItems]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND
[SwitchboardID]=" & Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)
End Sub
Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
Dim dbs As Database
Dim rst As Recordset
' Find the item in the tblSwitchboardItems table
' that corresponds to the button that was clicked.
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblSwitchboardItems",
dbOpenDynaset)
rst.FindFirst "[SwitchboardID]=" & Me![SwitchboardID]
& " AND [ItemNumber]=" & intBtn
End Function
know the newer ADO code. I have copied parts of the DAO
code.
The form's record source is tblSwitchboardItems. A
composite key consists of the SwitchboardID and
ItemNumber fields. Both fields are of the number data
type.
On the statement just before End Sub, I get the message
box error, "Run-time error '13'; Type mismatch."
On the statement just before End Function,
![SwitchboardID] gets highlighted in blue and I get the
message box error, "Compile error: Method or data member
not found." This is in spite of the fact that the table
has a field named SwitchboardID.
Any ideas as to how to rectify these errors? Thanks much
in advance.
Private Sub FillOptions()
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [tblSwitchboardItems]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND
[SwitchboardID]=" & Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)
End Sub
Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
Dim dbs As Database
Dim rst As Recordset
' Find the item in the tblSwitchboardItems table
' that corresponds to the button that was clicked.
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblSwitchboardItems",
dbOpenDynaset)
rst.FindFirst "[SwitchboardID]=" & Me![SwitchboardID]
& " AND [ItemNumber]=" & intBtn
End Function