On_click create a new record and populate it

Adrian510

Registered User.
Local time
Today, 17:05
Joined
Nov 24, 2005
Messages
38
I have a number of forms with options on and then the user clicks a command button which is meant to insert a an InstanceEnd time into the underlying table (the InstanceStart has already been populated) Create a new record and insert a new InstanceStart time into the new record the user is then led through the selection forms again and the whole process continues in a loop.

The problem i am having is that i am able to create the new records but the first one is the only one being populated. Code that i am using in the command button On_Click is below any help would be appreciated.

Regards

Adrian

Private Sub cmdStart_Click()

InstanceEnd = Time
DoCmd.GoToRecord , , acNewRec
InstanceStart = Time

DoCmd.Close
DoCmd.OpenForm "frmLineRunning", acNormal

End Sub





Private Sub cmdStop_Click()

InstanceEnd = Time
DoCmd.GoToRecord , , acNewRec
InstanceStart = Time

DoCmd.Close
DoCmd.OpenForm "frmDetailsCorrect", acNormal

End Sub
 
Hi,

I'm not sure what you are trying to achieve or whether your code will work, but I would venture to suggest that when your code executes:
DoCmd.GoToRecord , , acNewRec
it is just jumping to the same new record, where you are expecting it to save the current new record and start a new one.

I suggest you put:
DoCmd.RunCommand acCmdSaveRecord
before the GoToRecord line.

Hope that helps,
Keith.
 
that is exactly what is happening i will give it a go straight away.

Thanks for the response Keith i hope it works as a small win is needed at the moment :-)

Adrian
 
Hi Kieth

Still no joy perhaps a little more explination on my part is required

frmDetailsCorrect collects all the details of a production line process e.g. crew size, product name etc. based on selections made on previous forms in an enforced order. I am trying to collect the time that these processes take so when the command button start is clicked it actual enters an InstanceEnd time into the table the form is bound to (the InstanceStart is automatically entered when they open the first form as i need to acount for the time it takes users to select all the details) It is then meant to insert a new InstanceStart time in a new record and go to a form named frmStopReason which has a command button on it that says stop and when it is clicked it inserts a InstanceEnd time in the current record creats a new record and inserts a InstanceStart time before closing and opening frmDetailsCorrect.

I hope this had made it a bit clearer (not 100% sure it has :-) ) the crux of the problem is that i need to insert a time in a field in an existing record then creat a new record and insert a time into this record.

Regards

Adrian
 

Users who are viewing this thread

Back
Top Bottom