Programatically Enter Data Into Another Form

  • Thread starter Thread starter John
  • Start date Start date
J

John

My data has 10 accounts.

Two forms are opened simultaneously. Form1 is unbound and displays three
records:
Account Quantity
101 17
104 25
107 13

Form2 is a bound continuous form displaying records for all 10 accounts. The
records in Form2 include the Account#.

How can I programatically enter 17, 25, and 13 from Form1 to the Quantity field
in the records in Form2 where the Account#s are 101, 104 and 107 respectively?
The intent is to enter what's in Form1 into Form2, view the data from Form1
along side other data in Form2 and when Form2 is closed, save the data.

Appreciate all help!

John
 
John,

I hope this is a "tip" which will help... Forms do not have data, and
it often contributes to confusion if you think of data being in forms.
It usually helps me to realise that the data is stored in tables, while
the forms serve the purpose of providing an avenue for viewing and
interacting with the data.

Now as regards your question, I am a bit confused. If Form1 is unbound,
I don't know of any way to "display three records". Unless you mean
there are 6 unbound textboxes, all on the detail section of the form...
is this what you've got? If so, will there always be 6 textboxes to
represent 3 pairs of values, or will there sometimes be more or less? I
feel the simplest approach would be to base Form1 on a table, and then
use an Update Query to "transfer" the values entered to the main table
as represented by Form2.
 
Steve,

Thanks for the response and the tip.

Yes, there will there always be 6 textboxes all on the detail section of the
form and they represent 3 pairs of values. One or more pairs may be blank.

John
 
John,

As mentioned before, I would recommend making a table to temporarily
hold the values you want to put into your main table, and bind your
Form1 to this table. Then it is a simple Update Query to do what you want.

However, there would be a few approaches to using your existing setup.
For example, use a VBA procedure to run 3 update queries, one for each
potential pair of values, something like this...
If IsNull(Me.Textbox1 + Me.Textbox2) Then
' move on
Else
CurrentDB.Execute "UPDATE MyTable SET Quantity=" & Me.Textbox2 & "
WHERE Account=" & Me.Textbox1
End If
 
Back
Top