472,985 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

Having trouble with verifying if data exists in an Access 2013 table

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?
Nov 5 '16 #1

✓ answered by PhilOfWalton

Without going into too much detail, I think you need to reconsider your method completely.

A few general pointers before I start.
IMO there should never be spaces in field names. You have to put square brackets[] round the field name and that complicates things.
Same thing applies to table names.
Also consider the name of a field. You have to type it out each time. Do you really need "Students_in_Lab", would not "Students" do just as well?
Although "ID" is perfectly OK, wouldn't "StudentID" be much more descriptive.

Enough of that.

Now we get on to the area where so many people go wrong - Normalisation, and I suggest you read up on this as it is the key to successful relational database design.

Briefly it means one table for one thing that has an independent existence. In your case, a Student with a name, birthday, sex, hair colour etc. exists in his or her own right. It is irrelevant whether or not they are in or out of your wife's lab.

You need a table of Students with the StudentID as an AutoNumber and the prime key.
You need a table of InOut times with StudentID as the foreign key and LoggedIn and LoggedOut times.

So in principal the student has to exist in the student table before he can log in. We then check the In/Out status for that student. If the last entry for that student was in the "Out" column, a new record is created with the new "In" time, and if the last entry was in the "In" column, the "out time" is entered.

Phil

1 4501
PhilOfWalton
1,430 Expert 1GB
Without going into too much detail, I think you need to reconsider your method completely.

A few general pointers before I start.
IMO there should never be spaces in field names. You have to put square brackets[] round the field name and that complicates things.
Same thing applies to table names.
Also consider the name of a field. You have to type it out each time. Do you really need "Students_in_Lab", would not "Students" do just as well?
Although "ID" is perfectly OK, wouldn't "StudentID" be much more descriptive.

Enough of that.

Now we get on to the area where so many people go wrong - Normalisation, and I suggest you read up on this as it is the key to successful relational database design.

Briefly it means one table for one thing that has an independent existence. In your case, a Student with a name, birthday, sex, hair colour etc. exists in his or her own right. It is irrelevant whether or not they are in or out of your wife's lab.

You need a table of Students with the StudentID as an AutoNumber and the prime key.
You need a table of InOut times with StudentID as the foreign key and LoggedIn and LoggedOut times.

So in principal the student has to exist in the student table before he can log in. We then check the In/Out status for that student. If the last entry for that student was in the "Out" column, a new record is created with the new "In" time, and if the last entry was in the "In" column, the "out time" is entered.

Phil
Nov 5 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
0
by: harry12 | last post by:
Hello- I'm fairly new at using Microsoft Access and I'm having trouble getting a couple of things to work in my database. The first is that I have yet to find a way to get an append query to...
5
by: jonathanlim | last post by:
I am trying to append data to my local access database from an oracle connected database. I tried using the default query function but it take a very long time and it sort of hangs there and no...
3
by: kchang77 | last post by:
Good morning. I have two tables (Batches) and (Archive). (Batches) is a linked table that contains all of the existing data and the other (Archive) I am keying data into, through a form. I want...
2
by: ags5406 | last post by:
I've looked at lots of solutions for this but I must say that I'm thoroughly confused. VB2005... Let's say I've created a table in an access database called Table1 that has two columns and...
4
by: KMEscherich | last post by:
Version of Access = 2003 Hi there, is there a way to capture data using TERADATA SQL Assistant and import a portion of this database table into a Microsoft Access database table??? I currently...
1
by: NightGod | last post by:
I'm having trouble getting this query worked out. In my table, the relevant fields (with descriptions) are: SKU(the Item Number), StorageType (the type of rack the item is stored in, IE: pallet,...
2
by: msilva100 | last post by:
I have 3 combo box's in MS Access 2013 Manufacture, Brand, Product Group When I filter on one combo box I want the other 2 combo box's reflect results of filter. So when one Combo box is...
1
by: imran ashraf | last post by:
I have made a simple internis database in access 2013(having single table and single form)for storing details of all internis.. now i want to insert search options that can search records either...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.