Combo box macro doesn't work

C

Cindy

GRRR!!! I am trying to put a combo box button on a form to find the PO
Number to update. I have used the wizard to put an embedded macro in After
Update and I have done it manually but I cannot get it to work. The combo
box shows the PO Numbers from the table but when I click on the one I want I
get an error box that says:

Expected: identifier and then the macro error box showing error 2950.

In the macro I have 'Search for Record' and First and in the Where I have
="[PO Number]= " & Str(Nz([Screen].[ActiveControl],0))

Record source is the Purchase Order Table where the field PO Number is. I
have tried it with both just the table listed and with a Select statement.

I have made sure the locations are trusted, I am the administrator and I
have enabled Macros.

I have used this same combo box in another database I designed that works
perfectly on the same computer.

So what in the world can I be overlooking or doing wrong?

Thanks for any help. Cindy
 
J

John W. Vinson

GRRR!!! I am trying to put a combo box button on a form to find the PO
Number to update. I have used the wizard to put an embedded macro in After
Update and I have done it manually but I cannot get it to work. The combo
box shows the PO Numbers from the table but when I click on the one I want I
get an error box that says:

Expected: identifier and then the macro error box showing error 2950.

In the macro I have 'Search for Record' and First and in the Where I have
="[PO Number]= " & Str(Nz([Screen].[ActiveControl],0))

What is the datatype of PO Number? Number or Text?

More to the point, why are you using the (nonspecific) Screen.ActiveControl
rather than the unambiguous [Comboboxname]?

Assuming that the field is numeric, a criterion of

"[PO Number] = " & [comboboxname]

should work; if it's text, you need the syntactically required quotemarks:

"[PO Number] = '" & [comboboxname] & "'"
 
C

Cindy

John,

Hmm, well I changed the criterion to the actual combobox name. I got the
same error; Expected: Identifier

The data type is a number. This field is the Primary key which is set for
AutoNumber.

I have researched Identifier until I'm blue in the face and cannot find
anything I'm leaving out but it's always hard to see the most glaring mistake
when you've looked at it so long.

Is there a VBA code that I could use on this that might eliminate any
'trust' issues? I'm just learning VBA so be gentle with me. LOL

Thanks for all the great help you always share!

Cindy

John W. Vinson said:
GRRR!!! I am trying to put a combo box button on a form to find the PO
Number to update. I have used the wizard to put an embedded macro in After
Update and I have done it manually but I cannot get it to work. The combo
box shows the PO Numbers from the table but when I click on the one I want I
get an error box that says:

Expected: identifier and then the macro error box showing error 2950.

In the macro I have 'Search for Record' and First and in the Where I have
="[PO Number]= " & Str(Nz([Screen].[ActiveControl],0))

What is the datatype of PO Number? Number or Text?

More to the point, why are you using the (nonspecific) Screen.ActiveControl
rather than the unambiguous [Comboboxname]?

Assuming that the field is numeric, a criterion of

"[PO Number] = " & [comboboxname]

should work; if it's text, you need the syntactically required quotemarks:

"[PO Number] = '" & [comboboxname] & "'"
--

John W. Vinson [MVP]


.
 
J

John W. Vinson

John,

Hmm, well I changed the criterion to the actual combobox name. I got the
same error; Expected: Identifier

Sounds like the combo box is NULL at the time.
The data type is a number. This field is the Primary key which is set for
AutoNumber.

I have researched Identifier until I'm blue in the face and cannot find
anything I'm leaving out but it's always hard to see the most glaring mistake
when you've looked at it so long.

Is there a VBA code that I could use on this that might eliminate any
'trust' issues? I'm just learning VBA so be gentle with me. LOL

Anything you can do with macros can be done with VBA code... with the
advantage that VBA code is easier to debug and to error trap. A2007 macros are
better in this regard but there's still no competition.

Since you didn't post the steps of the macro or describe in detail what you
want it to do, I can't write the code for you... I'm quite willing to do so if
you'ld post that info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top