From: jerseygirl54 on
Thanks to all in advance for all the help you provide! :-)

I am "green" when it comes to any code so, once again, need real simple
instructions.

I have a "SearchLastName", which searches a list of names and then opens up
a person's information. Right now, if the person is not on the list, or if
the name is misspelled, the error macro code comes up or it brings up a blank
information box.

I would like to know what and where to put a code so that if someone types a
name that is not on the list or it is misspelled, a message box will pop up
to state there is no such name, check the spelling.

Thanks!
From: Ken Snell (MVP) on
You'll need to post your code so that we can see how you're doing the
search, and then we can provide a suggestion for how to trap for "no such
person".

--

Ken Snell
<MS ACCESS MVP>


"jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
news:0DFB44CE-5713-4D02-A8A2-6966A4F3F839(a)microsoft.com...
> Thanks to all in advance for all the help you provide! :-)
>
> I am "green" when it comes to any code so, once again, need real simple
> instructions.
>
> I have a "SearchLastName", which searches a list of names and then opens
> up
> a person's information. Right now, if the person is not on the list, or
> if
> the name is misspelled, the error macro code comes up or it brings up a
> blank
> information box.
>
> I would like to know what and where to put a code so that if someone types
> a
> name that is not on the list or it is misspelled, a message box will pop
> up
> to state there is no such name, check the spelling.
>
> Thanks!


From: jerseygirl54 on
I have attached a macro to the switchboard that is called "LastNameSearch":
OpenForm
Form Name: Students
Filter Name: OfficerRoster Query

I have created a Query - "OfficerRoster Query" that has:
Officer ID LastName FirstName

and in the "Last Name" Column it is sorted Ascending and then in its
"Criteria" I have the following:

Like "*" &[Enter Last Name]& "*"

"Ken Snell (MVP)" wrote:

> You'll need to post your code so that we can see how you're doing the
> search, and then we can provide a suggestion for how to trap for "no such
> person".
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
> news:0DFB44CE-5713-4D02-A8A2-6966A4F3F839(a)microsoft.com...
> > Thanks to all in advance for all the help you provide! :-)
> >
> > I am "green" when it comes to any code so, once again, need real simple
> > instructions.
> >
> > I have a "SearchLastName", which searches a list of names and then opens
> > up
> > a person's information. Right now, if the person is not on the list, or
> > if
> > the name is misspelled, the error macro code comes up or it brings up a
> > blank
> > information box.
> >
> > I would like to know what and where to put a code so that if someone types
> > a
> > name that is not on the list or it is misspelled, a message box will pop
> > up
> > to state there is no such name, check the spelling.
> >
> > Thanks!
>
>
>
From: Ken Snell (MVP) on
Your setup does not lend itself to an easy trapping when the user enters a
name that is not in the table / query. That's because you're having the
query ask for the name via a parameter, and the query cannot trap the error.

However, what you could do is use a macro on the "Students" form's Load
event that tests to see if the form has a record or not, and if not, close
the form and provide a message to the user.

Condition: Forms!Students.Recordset.RecordCount = 0
Action: MsgBox
Message: There is no such person in the database.

Condition: ...
Action: Close
Object Type: Form
Object Name: Students
Save: No

--

Ken Snell
<MS ACCESS MVP>



"jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
news:B3F64A74-9B8B-4ADE-A36B-E72B79293D43(a)microsoft.com...
>I have attached a macro to the switchboard that is called
>"LastNameSearch":
> OpenForm
> Form Name: Students
> Filter Name: OfficerRoster Query
>
> I have created a Query - "OfficerRoster Query" that has:
> Officer ID LastName FirstName
>
> and in the "Last Name" Column it is sorted Ascending and then in its
> "Criteria" I have the following:
>
> Like "*" &[Enter Last Name]& "*"
>
> "Ken Snell (MVP)" wrote:
>
>> You'll need to post your code so that we can see how you're doing the
>> search, and then we can provide a suggestion for how to trap for "no such
>> person".
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>>
>>
>> "jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
>> news:0DFB44CE-5713-4D02-A8A2-6966A4F3F839(a)microsoft.com...
>> > Thanks to all in advance for all the help you provide! :-)
>> >
>> > I am "green" when it comes to any code so, once again, need real simple
>> > instructions.
>> >
>> > I have a "SearchLastName", which searches a list of names and then
>> > opens
>> > up
>> > a person's information. Right now, if the person is not on the list,
>> > or
>> > if
>> > the name is misspelled, the error macro code comes up or it brings up a
>> > blank
>> > information box.
>> >
>> > I would like to know what and where to put a code so that if someone
>> > types
>> > a
>> > name that is not on the list or it is misspelled, a message box will
>> > pop
>> > up
>> > to state there is no such name, check the spelling.
>> >
>> > Thanks!
>>
>>
>>


From: jerseygirl54 on
Just a quick question -
When I click - "On Load" he VB screen appears. I click on Tools, then
Macros and it is allowing me to create a macro. Do I write the macro as you
wrote it below? Dumb question, I know! :-(

"Ken Snell (MVP)" wrote:

> Your setup does not lend itself to an easy trapping when the user enters a
> name that is not in the table / query. That's because you're having the
> query ask for the name via a parameter, and the query cannot trap the error.
>
> However, what you could do is use a macro on the "Students" form's Load
> event that tests to see if the form has a record or not, and if not, close
> the form and provide a message to the user.
>
> Condition: Forms!Students.Recordset.RecordCount = 0
> Action: MsgBox
> Message: There is no such person in the database.
>
> Condition: ...
> Action: Close
> Object Type: Form
> Object Name: Students
> Save: No
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
>
> "jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
> news:B3F64A74-9B8B-4ADE-A36B-E72B79293D43(a)microsoft.com...
> >I have attached a macro to the switchboard that is called
> >"LastNameSearch":
> > OpenForm
> > Form Name: Students
> > Filter Name: OfficerRoster Query
> >
> > I have created a Query - "OfficerRoster Query" that has:
> > Officer ID LastName FirstName
> >
> > and in the "Last Name" Column it is sorted Ascending and then in its
> > "Criteria" I have the following:
> >
> > Like "*" &[Enter Last Name]& "*"
> >
> > "Ken Snell (MVP)" wrote:
> >
> >> You'll need to post your code so that we can see how you're doing the
> >> search, and then we can provide a suggestion for how to trap for "no such
> >> person".
> >>
> >> --
> >>
> >> Ken Snell
> >> <MS ACCESS MVP>
> >>
> >>
> >> "jerseygirl54" <jerseygirl54(a)discussions.microsoft.com> wrote in message
> >> news:0DFB44CE-5713-4D02-A8A2-6966A4F3F839(a)microsoft.com...
> >> > Thanks to all in advance for all the help you provide! :-)
> >> >
> >> > I am "green" when it comes to any code so, once again, need real simple
> >> > instructions.
> >> >
> >> > I have a "SearchLastName", which searches a list of names and then
> >> > opens
> >> > up
> >> > a person's information. Right now, if the person is not on the list,
> >> > or
> >> > if
> >> > the name is misspelled, the error macro code comes up or it brings up a
> >> > blank
> >> > information box.
> >> >
> >> > I would like to know what and where to put a code so that if someone
> >> > types
> >> > a
> >> > name that is not on the list or it is misspelled, a message box will
> >> > pop
> >> > up
> >> > to state there is no such name, check the spelling.
> >> >
> >> > Thanks!
> >>
> >>
> >>
>
>
>
 |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Auto-Fill a Form
Next: Relationships and lookup tables.