OK, so I'm helping my wife out & trying to develop an Access 2013 database that will be used on Windows PCs. They're setting up a special tutoring lab at her college where remedial students can take online refreshers for placement testing, so they need to know how many students come in on any given day, what their purpose is for coming to the lab, & how long they're in the lab.
I know I can't make it 100% foolproof, but I was trying to automate as much as possible the process. Essentially, the students type in their name & click a button. I was hoping to set up either a macro or a VBA module so that, when the button is clicked, it checks the existing table to see if the student is currently "logged in" for the lab; if they're already logged in, it'll display 1 form to say they're now "logged out", & if they're not already logged in it adds a new record to the table.
I'm trying to take it in steps, but I know I'll have to have it eventually check 3 of the fields (as they're only "logged in" if the table has an entry for that day with their name & a start time but no end time), but I'm having trouble getting it to just verify whether the name is there or not.
I thought I could do this with DLookup, but I'm not sure I have the syntax right on it.
Currently, I have the following for the database:
-- data is stored in the table "Students_in_Lab", which has the fields "ID", "Student Name", "Date in Lab", "Time Arrived" & "Time Left" (I haven't decided yet whether to use a calculated field in the table called "Total Time in Lab", or calculate that when the reports are run)
-- the main form is "Student Login", which has the textbox "Student_Name" & the command button "CommandOK"
-- the subsequent forms are named "Login Option" and "Logout Option"
My current code is:
Private Sub CommandOK_Click()
If Not IsNull(DLookup("[Student Name]", "[Students in Lab]", "[Student Name] = '" & [Student Login].Student_Name & "'")) Then
Form_Load ([Logout Option])
Else
Form_Load ([Login Option])
End If
Right now, it gives me the error message "Compile Error: Method or data member not found", with the ".Student_Name" section right after "[Student Login]" highlighted.
Not sure where I went wrong with this, or if I'm even on the right track with it. Any thoughts?