I am doing a data entry form in access 2003 that enters data into and ACCESS table. But I have a linked table in SQL Server 2008, and queries created ACCESS using the QBE grid run fine. I can joint the linked tables with ACCESS tables and update the linked SQL Server table. But, ihave a problem doing a select query to the linked table from VBA, and I am stumped. After an Account number is entered, on lost focus I run the following code;
'Add SQL to string for looking up Master_ID in
'Master Accounts Table on Server
Dim StrLUMID As String
StrLUMID = "SELECT Master_ID FROM"
StrLUMID = StrLUMID + " dbo_Master_Accounts"
StrLUMID = StrLUMID + " WHERE (((dbo_Master_Accounts.Master_ID)=Card_No))"
'Set up select query
Dim cnndbo As ADODB.Connection
Set cnndbo = CurrentProject.Connection
Dim rsdbo As New ADODB.Recordset
rsdbo.ActiveConnection = cnndbo
rsdbo.CursorType = adOpenDynamic
rsdbo.LockType = adLockOptimistic
'Run Select query with String containing SQL
rsdbpen StrLUMID
'Interrogate the returned recordset to see if it
'matches the input card number. If not equal
'Display Message. If match, keep on truclin
If rsdbo.Fields(0).Value <> Card_No Then
MsgBox "Invalid Card Number"
Card_No.SetFocus
Else
End If
It bombs on the rsdbpen with "No value given for one or more of the required peramiters" and i can't get past this.
It's been trying, so any help would be appreciated.
Thanks in advance
'Add SQL to string for looking up Master_ID in
'Master Accounts Table on Server
Dim StrLUMID As String
StrLUMID = "SELECT Master_ID FROM"
StrLUMID = StrLUMID + " dbo_Master_Accounts"
StrLUMID = StrLUMID + " WHERE (((dbo_Master_Accounts.Master_ID)=Card_No))"
'Set up select query
Dim cnndbo As ADODB.Connection
Set cnndbo = CurrentProject.Connection
Dim rsdbo As New ADODB.Recordset
rsdbo.ActiveConnection = cnndbo
rsdbo.CursorType = adOpenDynamic
rsdbo.LockType = adLockOptimistic
'Run Select query with String containing SQL
rsdbpen StrLUMID
'Interrogate the returned recordset to see if it
'matches the input card number. If not equal
'Display Message. If match, keep on truclin
If rsdbo.Fields(0).Value <> Card_No Then
MsgBox "Invalid Card Number"
Card_No.SetFocus
Else
End If
It bombs on the rsdbpen with "No value given for one or more of the required peramiters" and i can't get past this.
It's been trying, so any help would be appreciated.
Thanks in advance