Open Subforms to new records

limawhiskey

New member
Local time
Today, 00:07
Joined
May 12, 2020
Messages
9
Hi Guys,

I am extremely new to Access and this is my first project using it, i'm normally an Excel kinda guy but like the flexibility and easier user elements of access.

I have a form which is linked to 5 different tables when the user selects a colleague it opens up their record. They will then have various tabs open which will be shown using VBA code on each of these tabs is a sub-form which needs completing each time it appears.

The first page which holds the colleagues key details will not change and can be updated so there will always be a single employee record and no duplicates. For each test undertaken on the other 5 tabs these will be individual each time and logging as a separate record on the corresponding table.

I have set the Data Entry to Yes on all sub-forms and even put code in the On Load event of each sub-form
Code:
DoCmd.GoToRecord , , acNewRec

However every-time I use it shows the same record and updates the same record rather than creating a new one.

Can anyone help me with this?

Thank you
 
Hi. Welcome to AWF! Are you able to post a sample copy of your db with test data?
 
Hi. Welcome to AWF! Are you able to post a sample copy of your db with test data?

Thanks for the quick response, sadly I cannot, I have tried to strip the system back and take all the data out to share but there are more problems with this due to how its setup with login forms and various checks including search forms etc. I have provided screenshots I know it's not as helpful.
Q1.png

Q2.png

Q3.png
 
As a first attempt I would try setting Data Entry to No on the Subforms and simply go with the

DoCmd.GoToRecord , , acNewRec

in the Form_Load event.

Linq ;0)>
 
As a first attempt I would try setting Data Entry to No on the Subforms and simply go with the

DoCmd.GoToRecord , , acNewRec

in the Form_Load event.

Linq ;0)>

Morning Linq,

I have just tried this and still getting the same result, I tested the code with a message box so I know its firing the load command.
 
What do you get when you try to use DoCmd.GoToRecord , , acNewRec ?
do you get a no value record? an error ?

How do you set your PF keys ?
 
What do you get when you try to use DoCmd.GoToRecord , , acNewRec ?
do you get a no value record? an error ?

How do you set your PF keys ?

Hi smig,

Thanks for the quick response. I don't get any errors it just runs but when I open the tab with the sub-form on it is already populated with the last entry for the selected individual. If there is no entry for the individual then the form is blank.

I don't believe I have set/touched my PF Keys - are these the Function Keys like F1 etc.
 
Hi smig,

Thanks for the quick response. I don't get any errors it just runs but when I open the tab with the sub-form on it is already populated with the last entry for the selected individual. If there is no entry for the individual then the form is blank.

I don't believe I have set/touched my PF Keys - are these the Function Keys like F1 etc.
Sorry i ment rhe PK-primary key
How do you set it? Is it an auto number?
 
Sorry i ment rhe PK-primary key
How do you set it? Is it an auto number?

Hi Smig,

On the employee table the primary Key is their employee number and on each of the sub-forms the primary key is an auto-number.

There relationship is based on the employee ID on each table.
 
I see no reason the DoCmd.GoToRecord , , acNewRec not to work
I feel other then uploading a strip version of your db it will be all some kind of guessing.
 
Morning,

I have managed to strip the database back.

The username is test and password is 1234.

Thank you :)
 

Attachments

check if this is what you want.
 

Attachments

ooh, I thought you are not able to add new record on colleagues.

i think the flow of the program is that only 1 record per patient.
and it's logical. if for sometime he comes back again and wants to
have a new test, you need to enter him again on (Main Menu->Add new colleague).
that is where the New record is, and supposed to be.
 
ooh, I thought you are not able to add new record on colleagues.

i think the flow of the program is that only 1 record per patient.
and it's logical. if for sometime he comes back again and wants to
have a new test, you need to enter him again on (Main Menu->Add new colleague).
that is where the New record is, and supposed to be.
Hi arnelgp,

The idea is there is one record for the individual but they may have many test records over the years as they come back time and time again.

The employee record will rarely change it will just have a record in each individual test table to show how many they have had etc.
 
at the bottom of Each subform, I enable the Record Navigation.
use this to add new record.
 

Attachments

Thanks arnelgp,

I have just noticed that if I put the DoCmd.GoToRecord , , acNewRec in the On Current event, it seems to load with a blank form.

I am conscious that I am new to this and as it wasn't suggested don't know if this is a good idea. Is there any negative to putting it in the on current event?

Thanks
 
it will keep on adding records (if you have at least a record).
and the intention is not obvious. (no button whatsoever, it
just add the record).

you don't want the idea of the Navigation button?
you can simply add a button on the Form's FormHeader section ("Add measurement").
when you change page, you also change the Caption of the command button.
 
I added some buttons as Helper and remove the Navigation button.
 

Attachments

Users who are viewing this thread

Back
Top Bottom