A
Andy Dorph
I cannot get the following to run wiuthout receiving an error message. I
have other queries exactly the same that work just fine in other forms.
I have read the other postings and ensured that the table field names and
form field names are correct.
When I copy it to SQL view and run it by clicking on the datasheet view, I
am asked for V_ID
Thanks in advance.
FYI: When I msgBox the query string it comes out just as I want it to
format. It is:
SELECT [V_Address1] FROM Vendor WHERE [V_ID] = 17
For the following, lstName is the name of a a ListBox
Dim GetVendorQuery As String
Dim rs As DAO.Recordset
intTO = lstName.Value
GetVendorQuery = "SELECT [V_Address1] FROM Vendor WHERE [V_ID] = " & intTO
Set rs = CurrentDb().OpenRecordset(GetVendorQuery)
If Not rs.BOF And Not rs.EOF Then
txtAddress1.Value = rs![V_Address1]
Else
MsgBox "No matching record. Please contact your Database
Administrator."
DoCmd.Close
End If
rs.Close
Set rs = Nothing
have other queries exactly the same that work just fine in other forms.
I have read the other postings and ensured that the table field names and
form field names are correct.
When I copy it to SQL view and run it by clicking on the datasheet view, I
am asked for V_ID
Thanks in advance.
FYI: When I msgBox the query string it comes out just as I want it to
format. It is:
SELECT [V_Address1] FROM Vendor WHERE [V_ID] = 17
For the following, lstName is the name of a a ListBox
Dim GetVendorQuery As String
Dim rs As DAO.Recordset
intTO = lstName.Value
GetVendorQuery = "SELECT [V_Address1] FROM Vendor WHERE [V_ID] = " & intTO
Set rs = CurrentDb().OpenRecordset(GetVendorQuery)
If Not rs.BOF And Not rs.EOF Then
txtAddress1.Value = rs![V_Address1]
Else
MsgBox "No matching record. Please contact your Database
Administrator."
DoCmd.Close
End If
rs.Close
Set rs = Nothing