How to make this login form??

R

Ron

Hello all,

I have a table FACULTY with FACULTYID and FACULTYPIN I want to make a
form with 2 textboxes on it one called txtFacultyID and one called
txtFacultyPIN.

A user will enter data into the two textboxes, if it matches what is in
the faculty table for that row it will open up another form, if the
facultyid and facultypin do not match, an error message box will pop
up. How would I do something like this?

So I want this to happen when my CMDLogin button is clicked. How would
I do this?


thanks.
 
G

Graham Mandeno

Hi Ron

Write some code in the Click event procedure of your cmdLogin button that
does a simple lookup to see is there are any records matching that ID and
PIN:

If DCount( "*", "FACULTY", "FACULTYID='" & txtFacultyID _
& "' and FACULTYPIN='" & txtFacultyPIN & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm ...
End If
 
R

Ron

OK, I tried this:...

Private Sub cmdlogin_Click()
If DCount("*", "FACULTY", "FACULTYID='" & txtfacultyid _
& "' and FACULTYPIN='" & txtfacultypin & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm "frmfaculty", , ,
"txtfacultyid=forms![frmfacultylogin]![facultyid]"

End If

End Sub

And when I click the LOGIN button I get an error Datatype mismatch in
criteria expression

?? for facultyID I am entering like 1112223 and for PIN 1133

Graham said:
Hi Ron

Write some code in the Click event procedure of your cmdLogin button that
does a simple lookup to see is there are any records matching that ID and
PIN:

If DCount( "*", "FACULTY", "FACULTYID='" & txtFacultyID _
& "' and FACULTYPIN='" & txtFacultyPIN & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm ...
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Ron said:
Hello all,

I have a table FACULTY with FACULTYID and FACULTYPIN I want to make a
form with 2 textboxes on it one called txtFacultyID and one called
txtFacultyPIN.

A user will enter data into the two textboxes, if it matches what is in
the faculty table for that row it will open up another form, if the
facultyid and facultypin do not match, an error message box will pop
up. How would I do something like this?

So I want this to happen when my CMDLogin button is clicked. How would
I do this?


thanks.
 
G

Graham Mandeno

Hi Ron

What are the data types or your two fields? I was assuming text but it
seems that one or both of them is numeric.

For a numeric field, you should not enclose the value in quote marks, but
you must also ensure that there *is* a value there if the user leaves one of
the textboxes blank. Assuming BOTH the fields are numeric, and 0 is invalid
for both of them, you can do this:

If DCount("*", "FACULTY", "FACULTYID=" & Nz(txtfacultyid,0) _
& " and FACULTYPIN=" & Nz(txtfacultypin,0) ) = 0 Then

The Nz function replaces a null value with the second argument (zero).
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Ron said:
OK, I tried this:...

Private Sub cmdlogin_Click()
If DCount("*", "FACULTY", "FACULTYID='" & txtfacultyid _
& "' and FACULTYPIN='" & txtfacultypin & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm "frmfaculty", , ,
"txtfacultyid=forms![frmfacultylogin]![facultyid]"

End If

End Sub

And when I click the LOGIN button I get an error Datatype mismatch in
criteria expression

?? for facultyID I am entering like 1112223 and for PIN 1133

Graham said:
Hi Ron

Write some code in the Click event procedure of your cmdLogin button that
does a simple lookup to see is there are any records matching that ID and
PIN:

If DCount( "*", "FACULTY", "FACULTYID='" & txtFacultyID _
& "' and FACULTYPIN='" & txtFacultyPIN & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm ...
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Ron said:
Hello all,

I have a table FACULTY with FACULTYID and FACULTYPIN I want to make a
form with 2 textboxes on it one called txtFacultyID and one called
txtFacultyPIN.

A user will enter data into the two textboxes, if it matches what is in
the faculty table for that row it will open up another form, if the
facultyid and facultypin do not match, an error message box will pop
up. How would I do something like this?

So I want this to happen when my CMDLogin button is clicked. How would
I do this?


thanks.
 
R

Ron

thanks! that did it. yes they were numeric fields.

Graham said:
Hi Ron

What are the data types or your two fields? I was assuming text but it
seems that one or both of them is numeric.

For a numeric field, you should not enclose the value in quote marks, but
you must also ensure that there *is* a value there if the user leaves one of
the textboxes blank. Assuming BOTH the fields are numeric, and 0 is invalid
for both of them, you can do this:

If DCount("*", "FACULTY", "FACULTYID=" & Nz(txtfacultyid,0) _
& " and FACULTYPIN=" & Nz(txtfacultypin,0) ) = 0 Then

The Nz function replaces a null value with the second argument (zero).
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Ron said:
OK, I tried this:...

Private Sub cmdlogin_Click()
If DCount("*", "FACULTY", "FACULTYID='" & txtfacultyid _
& "' and FACULTYPIN='" & txtfacultypin & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm "frmfaculty", , ,
"txtfacultyid=forms![frmfacultylogin]![facultyid]"

End If

End Sub

And when I click the LOGIN button I get an error Datatype mismatch in
criteria expression

?? for facultyID I am entering like 1112223 and for PIN 1133

Graham said:
Hi Ron

Write some code in the Click event procedure of your cmdLogin button that
does a simple lookup to see is there are any records matching that ID and
PIN:

If DCount( "*", "FACULTY", "FACULTYID='" & txtFacultyID _
& "' and FACULTYPIN='" & txtFacultyPIN & "'") = 0 Then
MsgBox "Authorization failed"
Else
DoCmd.OpenForm ...
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hello all,

I have a table FACULTY with FACULTYID and FACULTYPIN I want to make a
form with 2 textboxes on it one called txtFacultyID and one called
txtFacultyPIN.

A user will enter data into the two textboxes, if it matches what is in
the faculty table for that row it will open up another form, if the
facultyid and facultypin do not match, an error message box will pop
up. How would I do something like this?

So I want this to happen when my CMDLogin button is clicked. How would
I do this?


thanks.
 

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