Need help (1 Viewer)

history

Egyptian Pharaoh
Local time
Today, 06:04
Joined
Jan 26, 2008
Messages
190
Please brothers,
I need to know the meaning of this code ..... I took it from sample and tried to put it in my Inventory database but it failed .... cause ofcourse the code I didn't put right

Please I need to know the items refere to tables or records

thank you at all

The CODE:

Private Sub Code_AfterUpdate()
[Name] = DLookup("[Name]", "Names", "Code=
Code:
")
[Name] = DLookup("[Name]", "Names", "Code=[Code]")
[Price] = DLookup("[Price]", "Names", "Code=[Code]")
[Unit] = DLookup("[unit]", "Names", "Code=[Code]")
If IsNull(DLookup("[Code]", "Names", "[Code]='" & [Code] & "'")) Then
       MsgBox " Sorry this Code is not exist in our directory ... please correct it ", vbCritical
       Cancel = -1
      End If
End Sub
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:04
Joined
Jul 2, 2005
Messages
13,826
I would have to say you are using the wrong approach to your problem. What were you trying to accomplish when you copied this code? Explain your project a little better. Maybe someone will offer some suggestions as to how you can achieve the results you need.
 

Moniker

VBA Pro
Local time
Yesterday, 22:04
Joined
Dec 21, 2006
Messages
1,567
[Name] = DLookup("[Name]", "Names", "Code=
Code:
")
---Look up the value of field Name in the table Names where field Code equals the value of the code variable on a form---

[Name] = DLookup("[Name]", "Names", "Code=[code]")
---Same line as above---

[Price] = DLookup("[Price]", "Names", "Code=[code]")
---Look up the value of field Price in the table Names where field Code equals the value of the code variable on a form---

[Unit] = DLookup("[unit]", "Names", "Code=[code]")
---Look up the value of field unit in the table Names where field Code equals the value of the code variable on a form---

If IsNull(DLookup("[code]", "Names", "[code]='" & [code] & "'")) Then
---Look up the value of field code in the table Names where field Code equals the value of the code variable on a form. If it doesn't exist (IsNull), then show the message below and cancel the operation---

MsgBox " Sorry this Code is not exist in our directory ... please correct it ", vbCritical
Cancel = -1

Good luck with all that since you're not even sure what you're trying to do.  :)

It's pretty clear from your post and from the code that English isn't your first (or possibly second) language, so I'm not sure how much help we can be here.  You're not clear on what DLookups do, and the language barrier will probably only prove more confusing.
 

history

Egyptian Pharaoh
Local time
Today, 06:04
Joined
Jan 26, 2008
Messages
190
Dear Sir
Mr. Moniker
I'm very proud to hear from you ... it's very happy event for me to see your reply ... you're very right English isn't my first language where I'm Egyptian, but I think I can understand if you decided to help me and then I'll be appreciated ... don't think more about "language barriers"

Dear Sir,
Your comment is right that I don't know what Dlookups do ... but with my respect I know what I'm trying to do, may be my way is wrong but at least I'm trying to improve myself since I didn't find anyone to help me .... it's not a shame to try
BUT SURE IT'S SHAME TO UNDERESTIMATE THE TRYING TO LEARN

Thank you very much Mr. Moniker

sincerly
Omar El-Farouk Ahmed
Simple Egyptian Man
 

Moniker

VBA Pro
Local time
Yesterday, 22:04
Joined
Dec 21, 2006
Messages
1,567
No problem with a language barrier. I've helped lots of people that speak various languages (English, Spanish, French, etc.). The language barrier is this sense means that you don't understand the programming language more than anything else. Looking up "DLookup" in Access Help will show you exactly what it does, and it will provide examples. I provided the exact answer, but I don't think you'll get it because you're not understanding the basics.

I don't mean any offense, but if you don't understand the programming language, knowing what you want to do and knowing how to do it are completely different. I may know exactly how I want to build a house, but if I know nothing about construction, then it doesn't matter.
 

Users who are viewing this thread

Top Bottom