Confirm Data

  • Thread starter mattc66 via AccessMonster.com
  • 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.
 
D

Dirk Goldgar

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.
 
M

mattc66 via AccessMonster.com

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.
 
D

Dirk Goldgar

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.
 
Top