Ms access form query

baroom

Registered User.
Local time
Today, 05:06
Joined
May 29, 2009
Messages
19
HELLO
i have a form with two fields.
lets say item no and item name
it i enter item no then depending on this item no item name should be displayed from the table in the form.

i think this is very simple to u all .
please help me how to display the contents in the form from the table.

thankyou
 
Something like this, depending on whether Item No is numeric or text

'Item No is Text
Code:
Private Sub Item_No_AfterUpdate()
  Me.Item_Name = DLookup("[Item Name]", "YourTableName", "[Item No] = '" & Me.Item_No & "'")
End Sub
'Item No is Numeric
Code:
Private Sub Item_No_AfterUpdate()
 Me.Item_Name = DLookup("[Item Name]", "YourTableName", "[Item No] = " & Me.Item_No)
End Sub

Notice that if your actual names are Item No and Item Name, with spaces, Access will include an underscore in the code module. Having names with spaces is really a bad idea.
 
Thanks for your reply i did exactly as u said

Private Sub Item_No_AfterUpdate()
Me.Item_Name = DLookup("[Item Name]", "YourTableName", "[Item No] = '" & Me.Item_No & "'")
End Sub
but at the time of runniong the form it is giving me run time error what is the problem please tell me
how to sort out this situation.
 
Did you replace YourTableName with your actual table name?
 
HI,

I want to have the same functionality on the query also, I mean once i saved and then when i will open that record again so name should be populated as well?

Please tell me on which event will i have to write the same code?

Thanks & Regards
Asif
 

Users who are viewing this thread

Back
Top Bottom