Hi all.
My first post. I am a decent programmer in other environments but Access VBA is brand new to me. Although I have played successfully with Excel VBA.
I have a clients table with a client reference (ClientRef)and a description (ClientDesc). I have an orders Header table and an orders line item table.
The orders header table (SlsOrders) holds a client reference in a field called BillingClient which is the Control Source for a text box on my form SlsOrders. Beside this control I have a text box which I want to populate with the Client Name from the Clients table.
The BillingClient successfully populates BillingClient as one would expect. I want to use that value to collect the client description from the Clients table.
I am using the After Update event in the BillingClient object to collect it (or trying to!)
Here is my code
Private Sub BillingClient_AfterUpdate()
Dim RetVal As String
RetVal = ""
RetVal = DLookup("Clients", "ClientName", ClientRef = This.Value)
Forms![Form_SlsOrders]![BillToName].Value = RetVal
End Sub
First question is, do I need to refresh the form, and if do what is the syntax please. I am still struggling with syntax. Because ...
... it simply doesn't work. And I cannot step through it because debug will not work for me.
When I try to step through the code (F8) it just "boings"
I tried the "immediate" window to give it focus (from a search I did on here) by pasting in the code ...
Dim RetVal As String
RetVal = ""
RetVal = DLookup("Clients", "ClientName", ClientRef = This.Value)
Forms![Form_SlsOrders]![BillToName].Value = RetVal
... so that I could hit enter on each line, but it told me the code was invalid here.
I hope this post isn't to naive. But I have hunted in a number of places to find a solution.