Value in Text Box will not transfer to my table when I close the Form (1 Viewer)

hawzmolly

Registered User.
Local time
Today, 09:08
Joined
May 25, 2009
Messages
14
:banghead: I have a table that I am using to create a train manifest for our model railroad clubs operating sessions. I need to print the manifest after creation for the guys to use. I also need to be able to save the manifests for future use.

Here are the text fields I need to populate in the table: (These are my actual field names)
ABV, ABV1, ABV2 - These are the "Train Names". ABV is a concatenation of ABV1 and ABV2 i.e., [GNYO1 - AFCJC1]. The train names are derived from a table of all of the possible "Drop" or "Pick-up" locations. Example: GNYO1 = Green Bay North Yard Outbound Track 1.

See the attached pictures of the Forms - Design View and Form View and the Table. As you can see the data in the unbound text box to the right of T1 and T2 are filled in as well as the "Train Name" unbound text box. Now look at the Table view of my table (Manifest4.jpg) after saving and notice that ABV, ABV1, and ABV2 are not filled in. The ABV field is the field I need to use to save the data created.

Before I loose my mind beating my head against the wall please help with the code or any other pieces I should look at to be able to save the manifests created. I am using W7 Pro and Office 2010.
 

Attachments

  • Manifest1.JPG
    Manifest1.JPG
    33.1 KB · Views: 475
  • Manifest2.JPG
    Manifest2.JPG
    17.5 KB · Views: 474
  • Manifest3.JPG
    Manifest3.JPG
    38 KB · Views: 470
  • Manifest4.JPG
    Manifest4.JPG
    9.4 KB · Views: 454

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:08
Joined
Aug 30, 2003
Messages
36,126
If you're using an unbound form (one might ask why), then you must have code or a macro running to save the values to the table. It is in this code/macro that this field would have to be added (or perhaps an append query is being run).
 

hawzmolly

Registered User.
Local time
Today, 09:08
Joined
May 25, 2009
Messages
14
Below is the code I am using:

cbo161 is "Pickup Train", cbo107 is "Set out at", and "ABV" is a plain text field.

cbo 110 & 161 do indeed fill in the ABV, ABV1, and ABV2 text boxes on the form but do not transfer to the table. Obviously I am using the wrong code in "ABV" boxes to have it transfer to the table. TIA for any help with the code.

Private Sub ABV_AfterUpdate()
Me!ABV = Me!Combo161.Column(5) & "-" & Combo107.Column(4)
End Sub

Private Sub Combo107_AfterUpdate()
Area2 = Combo107.Column(1)
L2 = Combo107.Column(2)
T2 = Combo107.Column(3)
ABV2 = Combo107.Column(4)
Me.ABV = Combo161.Column(5) & "-" & Me.Combo107.Column(4)
End Sub



Private Sub Combo161_AfterUpdate()
Area1 = Combo161.Column(2)
L1 = Combo161.Column(3)
T1 = Combo161.Column(4)
ABV1 = Combo161.Column(5)
Me.ABV = Me.Combo161.Column(5)

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:08
Joined
Aug 30, 2003
Messages
36,126
All that does is take values from the selected item in the combo and put them in textboxes. To get into the table, either the form/textboxes need to be bound to the table/fields or some more code has to be running. Can you post the db here?
 

hawzmolly

Registered User.
Local time
Today, 09:08
Joined
May 25, 2009
Messages
14
The db is attached per your request. Form of interest is"Manifest - Build" and table of interest is "tblManifest".

Thank you.
 

Attachments

  • OperatingSession1.zip
    684.1 KB · Views: 482

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:08
Joined
Aug 30, 2003
Messages
36,126
The ABV1 and ABV2 textboxes are not bound to any field in the table like the others are.
 

hawzmolly

Registered User.
Local time
Today, 09:08
Joined
May 25, 2009
Messages
14
Yes, I think that is my problem. I can not figure out why I can't get these three fields bound to the table. Please use the "Manifest - Build" form and actually click on and add any one of the dropdown values under "Pick up Train". Note how "ABV1" and "Train Name" fill in. Then do the same for the first "Set Out At" combo. Again, note how the "ABV2" and the second part of "Train Name" fills in. What I can't seem to get my head around is how do I fill in the ABV, ABV1, and ABV2 fields in the "manifest" table. The reason I need to have the three fields is to be able to select the proper "Train Name" for later use. Also note that the "ABV" field is indexed and - no duplicates. Later I will be editing the base "Train Name" manifest for

There should be some code I can use under "After Update" or whatever, that I can use to get this done. However, I am not advanced enough to know how to write the code.

I have made a few changes and therefore I have re-attached the db.
 

Attachments

  • OperatingSession1.zip
    693.2 KB · Views: 219

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:08
Joined
Aug 30, 2003
Messages
36,126
I don't think it's a code problem. The control source of those text boxes isn't a field in the table, which they must be for the displayed value to save.
 

hawzmolly

Registered User.
Local time
Today, 09:08
Joined
May 25, 2009
Messages
14
I got rid of the "ABV" field and replaced it with Field Name "TrainName". With the following code it all works as expected.

Private Sub Combo161_AfterUpdate()
Area1 = Combo161.Column(1)
L1 = Combo161.Column(2)
T1 = Combo161.Column(3)
Text172 = Combo161.Column(4)

End Sub


Private Sub Combo107_AfterUpdate()
Area2 = Combo107.Column(1)
L2 = Combo107.Column(2)
T2 = Combo107.Column(3)
Text174 = Combo107.Column(4)
TrainName = Combo161.Column(4) & "-" & Me.Combo107.Column(4)
End Sub:D:D
 

Users who are viewing this thread

Top Bottom