MsgBox syntax incorrect?

mcgraw

Registered User.
Local time
Today, 10:22
Joined
Nov 13, 2009
Messages
77
I'm trying to debug some code, and see what is getting returned from a dlookup search, so I tried to put a MsgBox in that would display the dlookup result.

Code:
Dim groupID As Variant
    groupID = (DLookup("ID", "tblWithGroup", "issues.group_ID = " & [ID]))
    MsgBox("check me",vbOKOnly, "Check This", , "the groupID = " & groupID & ".")

But this just returns Syntax error, without any other details. This is my first try at doing a message box (yes, I am that new to this), so I'm not sure what I am doing wrong.

Any guidance would be GREATLY appreciated!
 
Try simply:

MsgBox "the groupID = " & groupID & "."

I think you have the message in the wrong place. You have it where the helpfile stuff would be.
 
Get rid of the parens when using a message box with it being in an equation:
Code:
 MsgBox "check me",vbOKOnly, "Check This the groupID = " & groupID & "."

Not sure about the commas, if you wanted them in there you would need them to be inside the quotes:
Code:
 MsgBox("check me",vbOKOnly, "Check This, , the groupID = " & groupID & ".")
 
Thanks!

I got the message box to pop up, but the groupID apparently doesn't have anything in it (I get "the group ID = .) ...which is why the rest of my code doesn't work! :)

Now to figure out where else I screwed up!

Thanks again, you guys are awesome!
 
This doesn't look right:

DLookup("ID", "tblWithGroup", "issues.group_ID = " & [ID])
 
I'm trying to get it to pull the group_ID field from the Issues table...and was thinking like a SQL statement...
 
But in the second argument you told it to look in the tblWithGroup table.
 
I want it to find the record where Issues.Group_ID = tblWithGroup.ID...

(and this is why I get so confused when trying to learn programming!)
 
Can you post the db? The fields aren't making sense to me, which probably means I need lunch. :p
 
Either lunch, or beer. I will need to strip it down and remove some information, but sure, I can put it up here.
 
Just a shotgun blast stab at it but how about:
Code:
groupID = DLookup("ID", "Issues", "[group_ID] = " & Me!ID)
 
the form itself is tied to the Issues table, so wouldn't me!ID = Issues ID, instead of the tblwithgroup.ID?
 
the form itself is tied to the Issues table, so wouldn't me!ID = Issues ID, instead of the tblwithgroup.ID?

You are looking for data FROM the ISSUES table, correct?

And you are looking for data that matches what is selected on the form, correct?

So, if that is the case, the code I gave should be what you want.

Are the ID's all numeric or are any text?
 

Users who are viewing this thread

Back
Top Bottom