Help on syntax for posting a form text field value to a field in the current row of the database (1 Viewer)

ChoiceTom

New member
Local time
Today, 07:30
Joined
Aug 6, 2020
Messages
9
Probably very basic, but I'm missing the correct syntax to take the value from a text-box field on a form and assign that value to a field in the database, current row.

The form properly opens to the next new row. This is a "child" form that opens when an "add record" button is pressed on the parent form.

Form fields directly linked to the DB via "select fields" options take entered data as you would expect. After using the form I check the DB and the new row was posted, with those fields filled in. The two fields I'm tinkering with are blank in the DB record because I don't have that handled correctly yet.

Those two fields are to receive openarg data from the parent form. I'm testing my basic form first just entering data to those, and looking to see that data posted to their fields.

Short Version: MS-Access form, most fields populated from the select fields function, but two fields as text-boxes. When I perform a "DoCmd.GoToRecord acDataForm, "EmplTrainLogMaint", acNewRec" a new row is properly created.

When I fill in all the fields on the form, they populate the database row properly except the two text boxes to their respective field destinations in that row. This is undoubtedly very basic syntax, just working this out at work amidst other duties.

Current attempt:

"Private Sub btnPostTraining_Click()

[emplTrainLog]![EmplID] = Me.TraineeID
Refresh

End Sub"


The "Refresh" actually posts the acNewRec transaction. I had assumed a simple reference to the table!field vs textbox on the form would be sufficient.

Thanks for your patience.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:30
Joined
Oct 29, 2018
Messages
13,692
Hi. Can you post a sample copy of your db with test data, so we can take a look?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:30
Joined
May 21, 2018
Messages
4,040
I am with @theDBguy, I do not understand your set up and cannot guess what is going on. It is hard to tell if this is a subform or pop up form. You mention openargs, but you do not show anything dealing with openargs. It is hard to tell which form has the values that you want.

One thing I do know
I had assumed a simple reference to the table!field
Will not work unless that table is the recordsource for a form. If you need to pull a value from another table you have to use a dlookup or other code.
 

ChoiceTom

New member
Local time
Today, 07:30
Joined
Aug 6, 2020
Messages
9
I am with @theDBguy, I do not understand your set up and cannot guess what is going on. It is hard to tell if this is a subform or pop up form. You mention openargs, but you do not show anything dealing with openargs. It is hard to tell which form has the values that you want.

One thing I do know

Will not work unless that table is the recordsource for a form. If you need to pull a value from another table you have to use a dlookup or other code.

I have a form. It is tied to a table. All of the fields pulled to the form from the "select fields" options post to their fields properly in the new record row in the database.

There are two unbound text box fields that will be receiving data. These are unbound text box fields.

When the new record actually posts to the database, those two fields in that database record should equal the contents of each of their corresponding unbound text fields on the form.

I am trying to identify the syntax of the function that lets me state [database-field1] = [form unbound text field 1], and [database-field2] = [form unbound text field2]

I haven't posted a copy of the database and app because I'm in the first stages of prototyping, hopping on and off the manufacturing floor between first piece calls. My posting the app at this stage is going to open an ocean's worth of dominoing "this isn't right" observations, many of which will likely be accurate but will be secondary to the question I'm trying to tweak out of the way.

Thanks kindly for the responses.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:30
Joined
Oct 29, 2018
Messages
13,692
Hi. I understand the hesitation, but since we are not familiar with your project, we can't (or having a hard time) imagine what you're describing. As such, it's hard to offer any suggestion if we don't understand the question. Are you able to post screenshots, at least?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:30
Joined
May 21, 2018
Messages
4,040
I am also still confused. If you cannot post then you will have to very precisely describe how this works. Need to include form names, recordsources, control names, control sources and all relevant code.

This is very confusing to me
There are two unbound text box fields that will be receiving data. These are unbound text box fields.
When the new record actually posts to the database, those two fields in that database record should equal the contents of each of their corresponding unbound text fields on the form
You have two unbound controls that you want to save the values to the table. Why are these not bound if you plan to save the values?
 

Users who are viewing this thread

Top Bottom