One Form Populating to another Form

G

Grizz

Here is a scenerio, I have a form already opened. I want to take but a
couple of the textboxes information off the current form and pass it to
another form when a button is pushed to open. Then be able to save the
information later to a table when needed.

This is the code I have in place on my current form to open the second form,
but my table is not being populated with the textboxes from the current form,
so this is not working.

Private Sub btnReceipt_Click()
On Error GoTo Err_btnReceipt_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Receipt"

stLinkCriteria = "[SampleID]=" & "'" & Me![SampleID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnSampleReceipt_Click:
Exit Sub

Err_btnSampleReceipt_Click:
MsgBox Err.Description
Resume Exit_btnSampleReceipt_Click

End Sub

This is why I would think it would be easier to populate the second forms
information from the first from then be able to save the information to the
table later. I know then I would rewrite the current form to just open up
the second form with the code to populate, which I do not know how. Hope you
all understand this, can you help

Thanks
 
J

Jeff Boyce

You've determined that the way to accomplish something is to take data
displayed on one form, move it to another form, then later save it to a
table.

But without an idea of WHAT you are trying to accomplish (you've described
HOW), it will be tough to offer suggestions ... it might be that there's an
alternate way to accomplish what you need to, if we only knew what it was!
<g>

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Grizz

ok suppose I have a form that already has the information populated in the
boxes, CustomerID, FName, LName, Addr. etc... I click a button to open
another form but I want the CustomerID, FName, LName, Addr to be already
loaded on the second form when opens. The second form has some true and
falses on the form sepperate from the original form. I am new at this and I
was wanting to know if I can accomplish this by populating the second form or
do I need to create a table to do this?

Jeff Boyce said:
You've determined that the way to accomplish something is to take data
displayed on one form, move it to another form, then later save it to a
table.

But without an idea of WHAT you are trying to accomplish (you've described
HOW), it will be tough to offer suggestions ... it might be that there's an
alternate way to accomplish what you need to, if we only knew what it was!
<g>

Regards

Jeff Boyce
Microsoft Office/Access MVP

Grizz said:
Here is a scenerio, I have a form already opened. I want to take but a
couple of the textboxes information off the current form and pass it to
another form when a button is pushed to open. Then be able to save the
information later to a table when needed.

This is the code I have in place on my current form to open the second
form,
but my table is not being populated with the textboxes from the current
form,
so this is not working.

Private Sub btnReceipt_Click()
On Error GoTo Err_btnReceipt_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Receipt"

stLinkCriteria = "[SampleID]=" & "'" & Me![SampleID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnSampleReceipt_Click:
Exit Sub

Err_btnSampleReceipt_Click:
MsgBox Err.Description
Resume Exit_btnSampleReceipt_Click

End Sub

This is why I would think it would be easier to populate the second forms
information from the first from then be able to save the information to
the
table later. I know then I would rewrite the current form to just open up
the second form with the code to populate, which I do not know how. Hope
you
all understand this, can you help

Thanks
 
J

Jeff Boyce

You are still explaining a HOW. Why do you feel that you must use a second
form?

If you can describe the underlying data structure and relationships (i.e.,
one-to-many, many-to-many), the 'group may be able to offer more
suggestions.

Right off the top, I wonder if you could use either a main-form/subform
approach, or perhaps a main-form with tab-control approach. With these
approaches, you would have no need to copy anything over to another form
(let alone another table).

Regards

Jeff Boyce
Microsoft Office/Access MVP

Grizz said:
ok suppose I have a form that already has the information populated in the
boxes, CustomerID, FName, LName, Addr. etc... I click a button to open
another form but I want the CustomerID, FName, LName, Addr to be already
loaded on the second form when opens. The second form has some true and
falses on the form sepperate from the original form. I am new at this and
I
was wanting to know if I can accomplish this by populating the second form
or
do I need to create a table to do this?

Jeff Boyce said:
You've determined that the way to accomplish something is to take data
displayed on one form, move it to another form, then later save it to a
table.

But without an idea of WHAT you are trying to accomplish (you've
described
HOW), it will be tough to offer suggestions ... it might be that there's
an
alternate way to accomplish what you need to, if we only knew what it
was!
<g>

Regards

Jeff Boyce
Microsoft Office/Access MVP

Grizz said:
Here is a scenerio, I have a form already opened. I want to take but a
couple of the textboxes information off the current form and pass it to
another form when a button is pushed to open. Then be able to save the
information later to a table when needed.

This is the code I have in place on my current form to open the second
form,
but my table is not being populated with the textboxes from the current
form,
so this is not working.

Private Sub btnReceipt_Click()
On Error GoTo Err_btnReceipt_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Receipt"

stLinkCriteria = "[SampleID]=" & "'" & Me![SampleID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnSampleReceipt_Click:
Exit Sub

Err_btnSampleReceipt_Click:
MsgBox Err.Description
Resume Exit_btnSampleReceipt_Click

End Sub

This is why I would think it would be easier to populate the second
forms
information from the first from then be able to save the information to
the
table later. I know then I would rewrite the current form to just open
up
the second form with the code to populate, which I do not know how.
Hope
you
all understand this, can you help

Thanks
 
G

Grizz

I already have a subform on my currrent form, by using a second form I am not
overcrowding more information that is needed. I did get my current form to
pass the information to my second form Where my text box control source is
=Forms!SampleForm!SampleID
My second form is Receipt
along with passing two other boxes from the Sample form to my closing form
using the same process
=Forms!SampleForm!CustomerID
=Forms!SampleForm!Date
But now I can not get it to post to my table
my two tables have the same relationship using the SampleID but for my
second table instead of reading from a table I want it to post to the table.

Ive tried [SampleID]=Forms!SampleForm!SampleID (blank In the box)
SampleID=Forms!SampleForm!SampleID (this too blank)
I've tried to reverse it too and nothing
How can I post this information to my SampleID in the receipt table? same
for the customerID and Date to the same table
 
J

John Vinson

I already have a subform on my currrent form, by using a second form I am not
overcrowding more information that is needed.

Consider using a Tab Page on the form. It lets you share "screen real
estate" without the problems caused by synchronizing two separate
forms.
I did get my current form to
pass the information to my second form Where my text box control source is
=Forms!SampleForm!SampleID

THat doesn't "pass" the information to the second form, it merely
displays a copy of the first form's field. The SampleID will not be
stored.
My second form is Receipt
along with passing two other boxes from the Sample form to my closing form
using the same process
=Forms!SampleForm!CustomerID
=Forms!SampleForm!Date

Don't use Date as the name of a field or control - it's a reserved
word, and Access WILL get confused.
But now I can not get it to post to my table
my two tables have the same relationship using the SampleID but for my
second table instead of reading from a table I want it to post to the table.

Ive tried [SampleID]=Forms!SampleForm!SampleID (blank In the box)
SampleID=Forms!SampleForm!SampleID (this too blank)
I've tried to reverse it too and nothing
How can I post this information to my SampleID in the receipt table? same
for the customerID and Date to the same table

First suggestion: Use a Subform, on a tab page.

Second suggestion: pass the SampleID in the OpenArgs argument of the
OpenForm method from your first form; use code in the second form's
Open event to set the DefaultValue property of the second form's
SampleID control to the value passed in OpenArgs.

John W. Vinson[MVP]
 
J

Jeff Boyce

Sorry if I haven't answered your question ... I don't feel I understand
enough about your situation yet to offer specific suggestions.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Grizz

Thank You John this was much help, as you can see I am new at this and your
help is much appreciated.

:
First suggestion: Use a Subform, on a tab page.

my Subform (which was my second form) on the tab was big and didn't correct
itself with a slider so only some would show. This is minor if I can get the
other to work.
Second suggestion: pass the SampleID in the OpenArgs argument of the
OpenForm method from your first form;

Ok I do believe I got this coded right
DoCmd.OpenForm "Receipt", OpenArgs:=Me![SampleID]
use code in the second form's
Open event to set the DefaultValue property of the second form's
SampleID control to the value passed in OpenArgs.

I do not understand How it looks to program the second form part?
 
J

John Vinson

Thank You John this was much help, as you can see I am new at this and your
help is much appreciated.

:
First suggestion: Use a Subform, on a tab page.

my Subform (which was my second form) on the tab was big and didn't correct
itself with a slider so only some would show. This is minor if I can get the
other to work.
Second suggestion: pass the SampleID in the OpenArgs argument of the
OpenForm method from your first form;

Ok I do believe I got this coded right
DoCmd.OpenForm "Receipt", OpenArgs:=Me![SampleID]
use code in the second form's
Open event to set the DefaultValue property of the second form's
SampleID control to the value passed in OpenArgs.

I do not understand How it looks to program the second form part?

Since I cannot see your form, it's hard indeed to give you code that
you can just plug in. But assuming that you have a control on the
second form named txtSampleID, you could use:

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then ' Is there an OpenArgs value?
Me.txtSampleID.DefaultValue = "'" & Me.OpenArgs & "'"
End If
End Sub

This will set the DefaultValue property (which must be a string) of
the txtSampleID control to

'123'

if the form is called with 123 as the SampleID.

John W. Vinson[MVP]
 
Top