unable to save records from subform (1 Viewer)

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
I have created a form which when one particular box is ticked opens a subform, the subform has several tick boxes which can be populated depending on answers received. In the subform i have a command button which runs a macro that saves the record to the main table, this is where i think i am going wrong. The subform closes and returns you to the main form, the rest of the details required are entered on the main form and it too has a save button, which closes the main form and saves the information to the same main table.
When I open the table to check what has and has not been saved, i find all the main form data is there but nothing that was entered into the subform.
Another problem is, that if i need to amend the subform data at a later date and i open it non of the data i previously entered is there, all the tick boxes etc are blank
Any ideas where im going wrong?
 

boblarson

Smeghead
Local time
Today, 13:23
Joined
Jan 12, 2001
Messages
32,059
A subform should not be saving records to the same table as the main form. If you need to do that, just put the controls on the main form (perhaps using a tab control).
 

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
Thanks for that but as a relative novice, you have lost me, is there a laymans way of explaining how i put the controls on the main form?
 

boblarson

Smeghead
Local time
Today, 13:23
Joined
Jan 12, 2001
Messages
32,059
Thanks for that but as a relative novice, you have lost me, is there a laymans way of explaining how i put the controls on the main form?

Perhaps if you post the database we can make some suggestions. It sounds like you might also have some normalization problems (from your descriptions) so that might be something we can address as well.

Here's how to upload
 

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
Thanks, enclosed is the database as you will see from the neqw event button, you open the input sheet, there are two buttons on the derailment and points run through, these open subforms which are the ones giving me grief
Thanks again
 

Attachments

  • HSQE Accidentc.zip
    532 KB · Views: 86

boblarson

Smeghead
Local time
Today, 13:23
Joined
Jan 12, 2001
Messages
32,059
 

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
Thanks for that Bob, however i need to make it so that the questions from the subform only appear when the has there been a derailment box is ticked, is this possible?
 

boblarson

Smeghead
Local time
Today, 13:23
Joined
Jan 12, 2001
Messages
32,059
Thanks for that Bob, however i need to make it so that the questions from the subform only appear when the has there been a derailment box is ticked, is this possible?

There are a couple of ways to do it.

1. Put something like "show" in the tag property of those controls you want to show only when the derailment box is ticked. Then, in the After Update of the derailment checkbox put
Code:
Dim ctl As Control
  For Each ctl In Me.Controls
       If ctl.Tag = "show" Then
          ctl.Visible = Me.Check58
       End If
  Next ctl

I would make sure to rename your controls to something useful as well so that it is obvious what Check58 is actually.

Then you should also put that same code in the form's Current event.

Or

2. You can place the controls on a tab control and make it visible if the checkbox is ticked or not.
 

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
Thanks yet again one last probl;em to solve then i will leave you in peace i promise. If i tick the derailment box, the questions appear and the answers are saved, no problem. if I then go back into that record at a latter time, the tick i placed in the tick box has disappeared and the questions have gone with it. If i retick it then the qustions reappear no problem. Is there a way of asking the user if they are sure they want to put a tick in this box and if they answer yes locking it ?
 

boblarson

Smeghead
Local time
Today, 13:23
Joined
Jan 12, 2001
Messages
32,059
Thanks yet again one last probl;em to solve then i will leave you in peace i promise. If i tick the derailment box, the questions appear and the answers are saved, no problem. if I then go back into that record at a latter time, the tick i placed in the tick box has disappeared and the questions have gone with it. If i retick it then the qustions reappear no problem. Is there a way of asking the user if they are sure they want to put a tick in this box and if they answer yes locking it ?
You need to bind the checkbox to a field if you want it to stay. And currently it isn't.

You can lock it by adding this to your After Update and Current events:

If Me.Check58 Then Me.Check58.Locked = True
 

ukmale65000

Registered User.
Local time
Today, 21:23
Joined
Nov 28, 2007
Messages
52
Thanks Bob that worked brilliantly, could not have done it without you
 

Users who are viewing this thread

Top Bottom