Abort if "Where" condition not met

B

Blakey300

Hi

I am using access 2007

I have 2 forms which are as follows:

Barcode Search Form (This is just a search form with unbound field)

Competitors (This form holds the data)

I have a macro that opens Competitors form using a where condition
(="[TempEntryID]=" & "'" & [Text0] & "'")

I would like to have it so that if the record is not found the the
competitors form is automatically closed and a messge box appears. then
reverts back to the barcode search form.

In summary I want

open competitors form where ="[TempEntryID]=" & "'" & [Text0] & "'" IF no
record found close Competitors, run message box then open barcode search form

Any help would be greatly appriecated

regards

dave
 
S

Steve Schapel

Dave,

Why do you want to open the Competitiors form if there is no matching
record? And then close it again? Any reason to just not open it in the
first place?
 
B

Blakey300

Because the form is opened automatically when a barcode is scanned. The 1st
form is an unbound search form.

So when a barcode is scanned it will go straight to the relevant record, but
if the record is not scanned i need it to abort the macro

Steve Schapel said:
Dave,

Why do you want to open the Competitiors form if there is no matching
record? And then close it again? Any reason to just not open it in the
first place?

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Hi

I am using access 2007

I have 2 forms which are as follows:

Barcode Search Form (This is just a search form with unbound field)

Competitors (This form holds the data)

I have a macro that opens Competitors form using a where condition
(="[TempEntryID]=" & "'" & [Text0] & "'")

I would like to have it so that if the record is not found the the
competitors form is automatically closed and a messge box appears. then
reverts back to the barcode search form.

In summary I want

open competitors form where ="[TempEntryID]=" & "'" & [Text0] & "'" IF no
record found close Competitors, run message box then open barcode search
form

Any help would be greatly appriecated

regards

dave
 
S

Steve Schapel

Hi Dave,

Sorry to be dense here. Can you tell us what are the Actions in your macro,
and what event is the macro assigned to i.e. what triggers it? How does the
ID value get written to the Text0 control on the Search Form?

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Because the form is opened automatically when a barcode is scanned. The
1st
form is an unbound search form.

So when a barcode is scanned it will go straight to the relevant record,
but
if the record is not scanned i need it to abort the macro

Steve Schapel said:
Dave,

Why do you want to open the Competitiors form if there is no matching
record? And then close it again? Any reason to just not open it in the
first place?

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Hi

I am using access 2007

I have 2 forms which are as follows:

Barcode Search Form (This is just a search form with unbound field)

Competitors (This form holds the data)

I have a macro that opens Competitors form using a where condition
(="[TempEntryID]=" & "'" & [Text0] & "'")

I would like to have it so that if the record is not found the the
competitors form is automatically closed and a messge box appears. then
reverts back to the barcode search form.

In summary I want

open competitors form where ="[TempEntryID]=" & "'" & [Text0] & "'" IF
no
record found close Competitors, run message box then open barcode
search
form

Any help would be greatly appriecated

regards

dave
 
B

Blakey300

Steve

My Macro is as follows:

Open Form Competitors
Where ="[TempEntryID]=" & "'" & [Text0] & "'"
Close Form Barcode Search

The macro is triggered via AfterUpdate of text0 control in the barcode
search form

The Value is entered into text0 via the barcode scanner (the barcode scanner
automatically types the barcode then presses enter which then fires the macro)

Steve Schapel said:
Hi Dave,

Sorry to be dense here. Can you tell us what are the Actions in your macro,
and what event is the macro assigned to i.e. what triggers it? How does the
ID value get written to the Text0 control on the Search Form?

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Because the form is opened automatically when a barcode is scanned. The
1st
form is an unbound search form.

So when a barcode is scanned it will go straight to the relevant record,
but
if the record is not scanned i need it to abort the macro

Steve Schapel said:
Dave,

Why do you want to open the Competitiors form if there is no matching
record? And then close it again? Any reason to just not open it in the
first place?

--
Steve Schapel, Microsoft Access MVP


Hi

I am using access 2007

I have 2 forms which are as follows:

Barcode Search Form (This is just a search form with unbound field)

Competitors (This form holds the data)

I have a macro that opens Competitors form using a where condition
(="[TempEntryID]=" & "'" & [Text0] & "'")

I would like to have it so that if the record is not found the the
competitors form is automatically closed and a messge box appears. then
reverts back to the barcode search form.

In summary I want

open competitors form where ="[TempEntryID]=" & "'" & [Text0] & "'" IF
no
record found close Competitors, run message box then open barcode
search
form

Any help would be greatly appriecated

regards

dave
 
S

Steve Schapel

Dave,

If it was mine, I would put a Condition for the OpenForm action, along the
lines of this:
DCount("*","NameOfTableCompetitorsFormBasedOn","[TempEntryID]='" & [Text0] &
"'")>0

Then again, I think if it was mine, I think I would dispense with the
Barcode Search form in any case, and use a SetTempVars macro to capture the
output of the barcode scanner, and then go straight to an OpenForm action in
which case the Condition something like:

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Steve

My Macro is as follows:

Open Form Competitors
Where ="[TempEntryID]=" & "'" & [Text0] & "'"
Close Form Barcode Search

The macro is triggered via AfterUpdate of text0 control in the barcode
search form

The Value is entered into text0 via the barcode scanner (the barcode
scanner
automatically types the barcode then presses enter which then fires the
macro)

Steve Schapel said:
Hi Dave,

Sorry to be dense here. Can you tell us what are the Actions in your
macro,
and what event is the macro assigned to i.e. what triggers it? How does
the
ID value get written to the Text0 control on the Search Form?

--
Steve Schapel, Microsoft Access MVP


Blakey300 said:
Because the form is opened automatically when a barcode is scanned. The
1st
form is an unbound search form.

So when a barcode is scanned it will go straight to the relevant
record,
but
if the record is not scanned i need it to abort the macro

:

Dave,

Why do you want to open the Competitiors form if there is no matching
record? And then close it again? Any reason to just not open it in
the
first place?

--
Steve Schapel, Microsoft Access MVP


Hi

I am using access 2007

I have 2 forms which are as follows:

Barcode Search Form (This is just a search form with unbound field)

Competitors (This form holds the data)

I have a macro that opens Competitors form using a where condition
(="[TempEntryID]=" & "'" & [Text0] & "'")

I would like to have it so that if the record is not found the the
competitors form is automatically closed and a messge box appears.
then
reverts back to the barcode search form.

In summary I want

open competitors form where ="[TempEntryID]=" & "'" & [Text0] & "'"
IF
no
record found close Competitors, run message box then open barcode
search
form

Any help would be greatly appriecated

regards

dave
 
S

Steve Schapel

....
DCount("*","NameOfTableCompetitorsFormBasedOn","[TempEntryID]='" &
[TempVars]![YourVar] & "'")>0

See, that way you reduce it from about 4 steps to 1.
 

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

Similar Threads


Top