PC Review


Reply
Thread Tools Rate Thread

Abort if "Where" condition not met

 
 
Blakey300
Guest
Posts: n/a
 
      23rd Sep 2009
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
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      23rd Sep 2009
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" <(E-Mail Removed)> wrote in message
news:7C6795CB-FCD3-4EBD-809D-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Blakey300
Guest
Posts: n/a
 
      23rd Sep 2009
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" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:7C6795CB-FCD3-4EBD-809D-(E-Mail Removed)...
> > 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

>
>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      24th Sep 2009
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" <(E-Mail Removed)> wrote in message
news:00139BA7-4B1C-47A0-9F96-(E-Mail Removed)...
> 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" wrote:
>
>> 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" <(E-Mail Removed)> wrote in message
>> news:7C6795CB-FCD3-4EBD-809D-(E-Mail Removed)...
>> > 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

>>
>>

 
Reply With Quote
 
Blakey300
Guest
Posts: n/a
 
      24th Sep 2009
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" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:00139BA7-4B1C-47A0-9F96-(E-Mail Removed)...
> > 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" wrote:
> >
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:7C6795CB-FCD3-4EBD-809D-(E-Mail Removed)...
> >> > 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
> >>
> >>

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      24th Sep 2009
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" <(E-Mail Removed)> wrote in message
news:BD0E4C1C-18B1-4B02-BBA3-(E-Mail Removed)...
> 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" wrote:
>
>> 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" <(E-Mail Removed)> wrote in message
>> news:00139BA7-4B1C-47A0-9F96-(E-Mail Removed)...
>> > 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" wrote:
>> >
>> >> 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" <(E-Mail Removed)> wrote in message
>> >> news:7C6795CB-FCD3-4EBD-809D-(E-Mail Removed)...
>> >> > 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
>> >>
>> >>

>>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      24th Sep 2009
....
DCount("*","NameOfTableCompetitorsFormBasedOn","[TempEntryID]='" &
[TempVars]![YourVar] & "'")>0

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

--
Steve Schapel, Microsoft Access MVP


"Steve Schapel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting: How to set condition "formula" with is "date"formatted AA Arens Microsoft Excel Discussion 10 31st Jan 2008 01:57 AM
Outlook 2003 rules: Can one specify "AND" vice "OR" condition =?Utf-8?B?Wm9yYW4gZnJvbSBCLWluLXRoZS11aw==?= Microsoft Outlook Discussion 0 26th Oct 2006 12:27 PM
"Rule based design" or "event-condition-action" pattern? feng Microsoft VB .NET 1 28th Feb 2005 09:18 AM
Outlook 2002 SP3 -> Tasks -> Custom Filter -> Advanced - ignores condition/value "between"/"last year and next friday" pluto@jupiter.info Microsoft Outlook 1 27th Jan 2005 05:11 PM
Customize Current View > Filter > Advanced > Feild="Location", Condition="is not empty" =?Utf-8?B?SnVzdGlu?= Microsoft Outlook Calendar 5 24th Mar 2004 03:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:20 PM.