Confirm Data

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date Start date
M

mattc66 via AccessMonster.com

Hi All,

I need to confirm the existance of specific data in my If statement.

However the data is located in on subform and the code is run from another
subform.

I need to check to see if the word ROOM is in the fld called ITEM. If it is
it runs query1 if not it runs query2.

Current Code:
If Forms![Orders]![sfrmOrderSubform].Form![Item] = "ROOM" Then
DoCmd.OpenQuery "query1", acViewNormal
Else
DoCmd.OpenQuery "query2", acViewNormal
End If

The system doesn't like my code.
 
mattc66 via AccessMonster.com said:
Hi All,

I need to confirm the existance of specific data in my If statement.

However the data is located in on subform and the code is run from
another subform.

I need to check to see if the word ROOM is in the fld called ITEM. If
it is it runs query1 if not it runs query2.

Current Code:
If Forms![Orders]![sfrmOrderSubform].Form![Item] = "ROOM" Then
DoCmd.OpenQuery "query1", acViewNormal
Else
DoCmd.OpenQuery "query2", acViewNormal
End If

The system doesn't like my code.

You don't tell us what the system actually *says* about your code --
that might help us figure out what's wrong.

I don't see anything syntactically wrong with what you posted. Make
sure that "sfrmOrderSubform" is actually the name of the subform
*control* on form Orders, and not just the name of the form object that
the subform control is displaying.
 
Actually it was a typo on my part, but now that it works I have a new problem.
It wants to update all the records. I only want it to run the update on the
current records. How would I control that?

Dirk said:
[quoted text clipped - 14 lines]
The system doesn't like my code.

You don't tell us what the system actually *says* about your code --
that might help us figure out what's wrong.

I don't see anything syntactically wrong with what you posted. Make
sure that "sfrmOrderSubform" is actually the name of the subform
*control* on form Orders, and not just the name of the form object that
the subform control is displaying.
 
mattc66 via AccessMonster.com said:
Actually it was a typo on my part, but now that it works I have a new
problem. It wants to update all the records. I only want it to run
the update on the current records. How would I control that?

It's hard to say, since I have no idea what this update consists of.
Are those queries your code was opening update queries? If that's the
update you're talking about, you'll need to apply criteria in those
queries that refer to controls on the form.
 

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

Back
Top