Reputation: 237
Is it possible to replicate this with just VBA instead of using SQL?
txtSCDate.Value = "SELECT [SC Date] FROM [Stock Conversion] WHERE [SCID] = " & txtSCNumber.Value & ";"
If not then how do you run that SQL from the VBA?
Thanks in advance, Bob P
Upvotes: 2
Views: 866
Reputation: 91336
You can use DLookUp:
txtSCDate.Value = DlookUp("[SC Date]","[Stock Conversion]","SCID = " _
& txtSCNumber.Value)
Note that you can set the control source of a textbox to a domain function such as DLookUp.
If you wanted to use SQL, then:
Dim rs As Recordset
sSQL = "SELECT [SC Date] FROM [Stock Conversion] WHERE SCID = " _
& txtSCNumber.Value
Set rs = CurrentDB.Openrecordset(sSQL)
Me.txtSCNumber = rs![SC date]
Upvotes: 3