Parameter in a Form

G

Guest

Hello,

I have created a form based on a table. On the form I set a parameter to
search for Student ID. If the ID entered matches a record, it will display
the form with the student information. The problem comes when it does not
match a record in a table, the form pops up with a gray background...no
fields are displayed...just a big gray box.

Is there a way to have the form requery the table if there is no matching
record to display? If the Student ID entered does not match a record in a
table, perhaps we can have a dialog box "please enter another Student ID"
until the ID matches a record in the table. Any help or insight on this would
be greatly appreciated.

Thank you in advance,
Bagia
 
G

Guest

What parameter are you setting and how? Are you doing this when you try to
open the form, maybe in the OpenForm method?
Is is a single form, continuous, or datasheet?
Is the data entry property set to yes?
 
G

Guest

The same question was asked regarding matching a last name (rather than a
student ID) and I copied the solution that was given. You should be able to
apply the principal. Here it is below
--
NTC


Make a macro with the MsgBox action, and enter an appropriate message to
display. In the Condition (if you can't see a Condition column in the macro
design window, select it from the View menu), put the equivalent of this...
DCount("*","YourTable","[LastName]='" & [LastName] & "'")>0

Assign this macro on the Before Update event of your form, or the After
Update event of the LastName textbox on your form.
 
G

Guest

Hi Klatuu,

I've never done this before. I don't know what is the best method to get the
result that I needed. I've created a form based on a table. When I open the
form (a single form), it pulls the parameter from the query that I created to
enter the Student ID. The data entry property is set to yes.

When the Student ID matches a record from the table, it opens the record. IF
I enter a Student ID that DOESN'T match a record, I want a dialog to appear
advising me that there's no matching records and I want the parameter dialog
box to appear again until I enter a Student ID that matches a record from the
table.
I tried to follow the instructions from NTC below, but I was unsuccessful. I
hope you can help.

Thanks in advance,
Bagia
 
G

Guest

NTC,

Do I need to create a parameter query in order to get this to work? I tried
to create the condition in the macro, but it didn't work. Can you tell me if
my condition is incorrect?

DCount("*","tblStudents","[AU ID]='" & [AU ID] & "'")>0

I get an erro that my syntax is incorrect. :(

Thanks,
Bagia

NetworkTrade said:
The same question was asked regarding matching a last name (rather than a
student ID) and I copied the solution that was given. You should be able to
apply the principal. Here it is below
--
NTC


Make a macro with the MsgBox action, and enter an appropriate message to
display. In the Condition (if you can't see a Condition column in the macro
design window, select it from the View menu), put the equivalent of this...
DCount("*","YourTable","[LastName]='" & [LastName] & "'")>0

Assign this macro on the Before Update event of your form, or the After
Update event of the LastName textbox on your form.

--
Steve Schapel, Microsoft Access MVP





Bagia said:
Hello,

I have created a form based on a table. On the form I set a parameter to
search for Student ID. If the ID entered matches a record, it will display
the form with the student information. The problem comes when it does not
match a record in a table, the form pops up with a gray background...no
fields are displayed...just a big gray box.

Is there a way to have the form requery the table if there is no matching
record to display? If the Student ID entered does not match a record in a
table, perhaps we can have a dialog box "please enter another Student ID"
until the ID matches a record in the table. Any help or insight on this would
be greatly appreciated.

Thank you in advance,
Bagia
 

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

Top