We have an abundance of patience here...
sounds like you're starting from scratch... I'll pm you my boilerplate of tools. Please check your bytes.com inbox.
I'll give the most simplistic, crude, method here and once you work the tutorial in the boilerplate you'll be able to handle things in a more elegant method.
Normally a form is "bound" to a record source. What this means is that there is either a table or query that is associated with the form. The fields in the underlying table are then bound to the controls on the form.
For example, take a very simple table:
[tblone]![PK];[tblone]![FieldOne_text]; [tblone]![Fieldtwo_numeric]
(assume he datatype is indicated by the name)
So if you use the wizard to make the form, selecting this table as the recordsource. The form will have the record source property set to "tblone" and the the inserted controls will default to being named after their bound field as indicated in by their name and the "control source" property... in the this case: you would get three text box controls, named "PK", "FieldOne_text" and "Fieldtwo_numeric" this makes things confusing to say the least as the controls are NOT the fields.
To help illustrate this difference:
Open the form in design view.
Select one of the textbox controls and either in the ribbon or by rightclick show the control properties.
IN the {All}-Tab you can of course see all of the controls properties, the first field will be [name] (which is why you should not use that as a field-name), the second will be [Control Source] - using the wizard both are the same by default. Take a moment to look at each tab grouping so that you get an idea as to how the various properties are grouped... pay special attention to {data} and {events}
Lets change the control names so for each textbox on the form, go to either the {all} tab or the {other} tab and change the names (selecting each control of course (^_^) ).
ctrl_txt_PK
ctrl_txt_FieldOne_Text
ctrl_txt_FieldTwo_Numeric
There is a property "value" for each control and this is important... when you scroll thru the records on the form in normal view (or dataentry) the value of the currently selected record becomes the value of the control...
ctrl_txt_pk.value === value-of(currentrecord([tblone]![PK]))
following?
OK, next is your command button... add one to the form... cancel any wizards that show up.
Show the properties for the command button, and name it something useful, say, "ctrl_cmd_enterblack"
Goto the {events} tab for your command button...
Select the on_click event, click on the button with the three dots [...]
Select Code Builder
The VBA Editor window will open and you should have something like:
- Option Compare Database
-
Option Explicit
-
-
Private Sub ctrl_cmd_enterblack_Click()
-
-
End Sub
-
now in
-
Private Sub ctrl_cmd_enterblack_Click()
-
-
End Sub
-
enter
- me.ctrl_txt_fieldone_text.setfocus
-
me.ctrl_txt_fieldone_text.value = "black"
-
me.ctrl_cmd_enterblack.setfocus
The setfocus forces the entry in to the record, then we alter the field, and by default when we set the focus outside of the record the record is saved.
-
Private Sub ctrl_cmd_enterblack_Click()
-
me.ctrl_txt_fieldone_text.setfocus
-
me.ctrl_txt_fieldone_text.value = "black"
-
me.ctrl_cmd_enterblack.setfocus
-
End Sub
-
this is the basic, crude, method. There's no error checking and is expecting the user to know what they are doing... etc... dates would be surrounded in "#" strings in quotes, and numeric values are "as is"