Check for non-exiting IDs

G

Guest

The school I worked at wants me to create an application so student can fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student ID
(this is type in a text box), then he/she clicks in a command button to start
the survey. The command button should check that if it is a valid ID then
the survey screen should be displayed if not a message box will be displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the table then
it is an invalid ID.

Thank you for your help...
 
A

Arvin Meyer [MVP]

The answer is easy, and may be done several different ways Before we write
some code for you, what you want to do after it returns OK, (Open a specific
form, etc.) and what happens if (or when) the student types someone else's
ID by mistake and that ID does, in fact, exist?
 
G

Guest

If the ID is a valid one, then a new form (the survey) should be opened.

If the ID is invalid the "Splash" screen remains open an a Msgbox is
displayed.

If the ID is entered wrong three times the application terminates
automatically (I can do this one once I know how to check for an invalid ID)

Not every student will be filling surveys at the same time, the number of
students doing the survey at the same time will be less than 15.

If the student has filled-out a survey a yes/no field is set by my coding.

I am assuming that the chances that a student enters someone else's is very
slim. I could ask for SSN, the surveys are confidential but students might be
adamant about providing their SSN. (surveys will be about classes and
instructors' evaluations)

I hope this helps.
 
S

Steve

Assumimg StudentID is numeric, put the following code at the beginning of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Steve,

I copy/paste your code and change text to my own data. when I try to run it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh VBA
Screen.

Please help... Thank you

Steve said:
Assumimg StudentID is numeric, put the following code at the beginning of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


Ricoy-Chicago said:
The school I worked at wants me to create an application so student can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student ID
(this is type in a text box), then he/she clicks in a command button to
start
the survey. The command button should check that if it is a valid ID then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the table
then
it is an invalid ID.

Thank you for your help...
 
S

Steve

You mistyped that line of code. Here is what I gave you:
Dim DB as DAO.Database

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Ricoy-Chicago said:
Steve,

I copy/paste your code and change text to my own data. when I try to run
it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh
VBA
Screen.

Please help... Thank you

Steve said:
Assumimg StudentID is numeric, put the following code at the beginning of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


Ricoy-Chicago said:
The school I worked at wants me to create an application so student can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student ID
(this is type in a text box), then he/she clicks in a command button to
start
the survey. The command button should check that if it is a valid ID
then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the table
then
it is an invalid ID.

Thank you for your help...
 
G

Guest

Corrected typo... still same error... time to go home, I'll try tomorrow...

Steve said:
You mistyped that line of code. Here is what I gave you:
Dim DB as DAO.Database

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Ricoy-Chicago said:
Steve,

I copy/paste your code and change text to my own data. when I try to run
it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh
VBA
Screen.

Please help... Thank you

Steve said:
Assumimg StudentID is numeric, put the following code at the beginning of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


The school I worked at wants me to create an application so student can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student ID
(this is type in a text box), then he/she clicks in a command button to
start
the survey. The command button should check that if it is a valid ID
then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the table
then
it is an invalid ID.

Thank you for your help...
 
S

Steve

Open to the code. Go to Tools - References. Uncheck Microsoft ADO. Scroll
down and find Microsoft DAO with the highest version number. Check it.
Clsoe. Open Tools - References again. Microsoft DAO should now be in the
list and checked. Close. Try runnning the code again.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Ricoy-Chicago said:
Corrected typo... still same error... time to go home, I'll try
tomorrow...

Steve said:
You mistyped that line of code. Here is what I gave you:
Dim DB as DAO.Database

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Ricoy-Chicago said:
Steve,

I copy/paste your code and change text to my own data. when I try to
run
it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh
VBA
Screen.

Please help... Thank you

:

Assumimg StudentID is numeric, put the following code at the beginning
of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


message
The school I worked at wants me to create an application so student
can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student
ID
(this is type in a text box), then he/she clicks in a command button
to
start
the survey. The command button should check that if it is a valid
ID
then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the
table
then
it is an invalid ID.

Thank you for your help...
 
J

John W. Vinson

Corrected typo... still same error... time to go home, I'll try tomorrow...

PMFJI...

Open the VBA editor; on the menu select Tools... References. Scroll down and
check

Microsoft DAO x.xx Object Library

(check the highest version if there are more than one).

John W. Vinson [MVP]
 
G

Guest

THANX :- )

It works!!!

Steve said:
Open to the code. Go to Tools - References. Uncheck Microsoft ADO. Scroll
down and find Microsoft DAO with the highest version number. Check it.
Clsoe. Open Tools - References again. Microsoft DAO should now be in the
list and checked. Close. Try runnning the code again.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Ricoy-Chicago said:
Corrected typo... still same error... time to go home, I'll try
tomorrow...

Steve said:
You mistyped that line of code. Here is what I gave you:
Dim DB as DAO.Database

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Steve,

I copy/paste your code and change text to my own data. when I try to
run
it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh
VBA
Screen.

Please help... Thank you

:

Assumimg StudentID is numeric, put the following code at the beginning
of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


message
The school I worked at wants me to create an application so student
can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student
ID
(this is type in a text box), then he/she clicks in a command button
to
start
the survey. The command button should check that if it is a valid
ID
then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the
table
then
it is an invalid ID.

Thank you for your help...
 
G

Guest

You rock! This helped me out too!

Steve said:
Open to the code. Go to Tools - References. Uncheck Microsoft ADO. Scroll
down and find Microsoft DAO with the highest version number. Check it.
Clsoe. Open Tools - References again. Microsoft DAO should now be in the
list and checked. Close. Try runnning the code again.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




Ricoy-Chicago said:
Corrected typo... still same error... time to go home, I'll try
tomorrow...

Steve said:
You mistyped that line of code. Here is what I gave you:
Dim DB as DAO.Database

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)





Steve,

I copy/paste your code and change text to my own data. when I try to
run
it
the message:

Complie error:
User-defined type not defined

is displayed and the text : "DB as DOA.Database" is highilighted int eh
VBA
Screen.

Please help... Thank you

:

Assumimg StudentID is numeric, put the following code at the beginning
of
your code for the command button:

Dim DB as DAO.Database
Dim Rst As DAO.Recordset
Set DB = CurrentDB()
Set Rst = DB.OpenRecordset("TblStudent")
Rst.FindFirst "[Student] = " & Me!NameOfStudentIDTextBox
If Rst.NoMatch Then
GoTo ExitHere
End If

Put the following code right above End Sub:
ExitHere:
Set DB = Nothing
Rst.Close
Set Rst = Nothing

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)


message
The school I worked at wants me to create an application so student
can
fill
school surveys in the computer.

Using Acees 2000, F/E, B/E files tables, forms queries etc. I have
everything ready except for one thing:

I have a "splash" screen where the student will type his/her student
ID
(this is type in a text box), then he/she clicks in a command button
to
start
the survey. The command button should check that if it is a valid
ID
then
the survey screen should be displayed if not a message box will be
displayed.
I have a table with the Student ID and student's personal info.
I have no problem creating any of this my problem is:

How can I check if the Student ID is a valid one?

For example if the student types: 1000 and that ID is not in the
table
then
it is an invalid ID.

Thank you for your help...
 

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