Transfering values from one form to another - DLookup

anoo

Registered User.
Local time
Today, 03:51
Joined
Feb 10, 2017
Messages
17
SOLVED - Transfering values from one form to another - DLookup

Dear Experts,

I am trying to use DLookup to get values on a form.

On load event of form with code works

Text2 = DLookup("Colour", "tblData", "ID=2")
How to get that value "2" transferred from another form?

I tried this and does not work. Could anyone please help me?

Text4 = DLookup("Colour", "tblData", "ID=" & Forms!Form1!Text0 --> does not work


Microsoft example:

=DLookup("[ProductName]", "Products", "[ProductID] =" & Forms![Order Details]!ProductID)
Thank you so much for your help.
 

Attachments

Last edited:
Assuming your other form is called form1 and the Control with the value you are looking for is called Text0 , and the form is open then your example should work. What error are you getting?

Text4 = DLookup("Colour", "tblData", "ID=" & Forms!Form1!Text0 )
 
Thank you, Minty

Runtime error 3075 Syntax error with this code, Thanks. File attached.

Option Compare Database
Private Sub Form_Load()
Text2 = DLookup("Colour", "tblData", "ID=2")
Text4 = DLookup("Colour", "tblData", "ID=" & Forms!Form1!Text0)
End Sub
 

Attachments

Actually my remembering of the syntax was out slightly... Blush

Code:
Forms![Form1]![Text0]

See the attached.
 

Attachments

For me, in testing, the problem is that the Text0 Textbox is Unbound. If you Bind the Form1 to a Table, and have Text0 Bound to a Field in it, the code works as expected.

Linq ;0)>
 
Thank you, Minty and missinglinq. I really appreciate time taken to modify the database and made it work.

Marked as "SOLVED".
 
Glad we could help!

Good luck with your project!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom