Two forms writing to one record???? (1 Viewer)

Paddy1980

Registered User.
Local time
Today, 08:57
Joined
Jan 29, 2009
Messages
18
Hi I have a problem where I have one table that is split into two forms (one main and one as a pop up). I am also using autonumber ID (as the primary key).

Basically the problem I have is that I can fill out data in the main form which on selecting a response will trigger the pop up form with some check boxes. When a check box is ticked I want the information from the main form and the check box tick to save to the same record on the table, BUT it creates a new autonumber record (i.e. I have a main record with ID of 1 and a new one with only the check box ticked with an ID of 2)

So how can I get both forms to write to just one record?

An easy option is just to have the tick boxes within the main form but the client has specifically requested that a pop up (form) appears.

Any ideas?
 

DCrake

Remembered
Local time
Today, 08:57
Joined
Jun 8, 2005
Messages
8,626
It sounds like your popup form is adding a new record each time it opens. What you need to do is to say

DoCmd.OpenForm YourFormNameHere ,"[YourId]=" & MainFormID

This will open up the same record as the one on the main form, not a new record.

David
 

Paddy1980

Registered User.
Local time
Today, 08:57
Joined
Jan 29, 2009
Messages
18
I have the vb line

DoCmd.OpenForm "Popup form", , , "[ID]=" & Forms![Invoicing form]![ID]

and it still doesn't work
 

DCrake

Remembered
Local time
Today, 08:57
Joined
Jun 8, 2005
Messages
8,626
Have you got the Allow Additions setting set to No?
 

Paddy1980

Registered User.
Local time
Today, 08:57
Joined
Jan 29, 2009
Messages
18
No, I have tried setting it to 'No' on the pop up form but then the check box fields don't show, it's just the window and back colour
 

John Big Booty

AWF VIP
Local time
Today, 17:57
Joined
Aug 29, 2005
Messages
8,262
If you are on a new record when you are firing this command, you must first force the record to be written to the table, before your pop up can open at the same point. As although an AutoNumber (I'm assuming [ID] is an auto number, even if not this still applies) may have been assigned to the record, it is not written to the table until the record looses focus. Therefore there is nothing for the Pop up to link on.

Try;
Code:
Me.Refresh

DoCmd.OpenForm "Popup form", , , "[ID]=" & Me![ID]
 

John Big Booty

AWF VIP
Local time
Today, 17:57
Joined
Aug 29, 2005
Messages
8,262
You may also want to consider a method of preventing your pop up from adding a new record. You could do that by adding a close button and setting it as the last control in the tab order and simply set the focus back to the first control in the tab order when the button looses focus.
 

Paddy1980

Registered User.
Local time
Today, 08:57
Joined
Jan 29, 2009
Messages
18
I think that may have helped. Thank you

I also had set Data Entry to No on the popup and it seems to be working...
 

John Big Booty

AWF VIP
Local time
Today, 17:57
Joined
Aug 29, 2005
Messages
8,262
Dataentry = True (Yes) sets the form to only allow entry of New data. By setting it to false (No) it allows the user to view all records, but does not stop them from entering new records. The ability to entry new records is controlled by the allowAdditions property.
 

Users who are viewing this thread

Top Bottom