N
Nick T
Hi,
I use the following code in a click event on a command button in my form to
look up data in a table & insert the relevant info into text boxes on my
form. However, can I use this simular code to carry out the same function
but looking up the data in a query (as apposed to a table)??
I know it wont be exactly the same, but any suggestions on the code?
Any help would be great. Thanks.......
Private Sub Command9_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Addresses", dbOpenDynaset)
With rst
.FindFirst "[CustomerID] = " & Me.CustomerID
If .NoMatch Then
MsgBox "CustomerID " & Me.CustomerID & " Not Found in Client list"
Else
Me.FirstName = !FirstName
Me.LastName = !LastName
Me.PostalCode = !PostalCode
End If
Me.Command10.Enabled = True
.Close
End With
Set rst = Nothing
End Sub
I use the following code in a click event on a command button in my form to
look up data in a table & insert the relevant info into text boxes on my
form. However, can I use this simular code to carry out the same function
but looking up the data in a query (as apposed to a table)??
I know it wont be exactly the same, but any suggestions on the code?
Any help would be great. Thanks.......
Private Sub Command9_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Addresses", dbOpenDynaset)
With rst
.FindFirst "[CustomerID] = " & Me.CustomerID
If .NoMatch Then
MsgBox "CustomerID " & Me.CustomerID & " Not Found in Client list"
Else
Me.FirstName = !FirstName
Me.LastName = !LastName
Me.PostalCode = !PostalCode
End If
Me.Command10.Enabled = True
.Close
End With
Set rst = Nothing
End Sub