Fill in boxes on form automatically

H

HeatherM

I have a report that opens three forms in sequence, each
form asking for report criteria. I would like to fill the
boxes of the second form automatically without prompting
for input. I can't cut this step out of the report process
because the criteria are needed for a shared subreport and
I'm not keen on duplicating the subreport for every
possible variation of the main report.

so.....for form [frmSelectProject] I want text box [Text0]
to be AA0000 and text box [Text2] to be ZZ9999, and then
move onto the next form

What do I do after:
DoCmd.OpenForm "frmSelectProject", acNormal, "", "",
acEdit, acDialog
 
A

Andy Cole

Heather

As you are opening the criteria form in Dialog mode, the user would,
normally, be required to click something to either close/hide the form to
allow execution to return to the calling code. There are 2 possible
approaches;

1. Remove the acDialog parameter and then set the values and (presumably)
hide the criteria Form;

DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit
Forms!frmSelectProject!Text0 = "AA0000"
Forms!frmSelectProject!Text2 = "ZZ9999"
Forms!frmSelectProject.Visible = False
.....open the 3rd form

2. Leave the acDialog parameter, pass the two values using the OpenArgs
parameter, and in the OnLoad event of frmSelectProject, set the values and
then hide the form;

In the calling code;
Dim strOA As String

strOA = "AA0000|ZZ9999"
DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit, acDialog, strOA
.....open the 3rd form

In On Load event of frmSelectProject

Dim strOA() As String

strOA = Split(Me.OpenArgs, "|")
If UBound(strOA) > 0 Then
Me.Text0 = strOA(0)
Me.Text2 = strOA(1)
Me.Visible = False
End If

HTH

Andy
 
H

HeatherM

Thanks Andy!
Option 1 worked perfectly

Regards,
Heather
-----Original Message-----
Heather

As you are opening the criteria form in Dialog mode, the user would,
normally, be required to click something to either close/hide the form to
allow execution to return to the calling code. There are 2 possible
approaches;

1. Remove the acDialog parameter and then set the values and (presumably)
hide the criteria Form;

DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit
Forms!frmSelectProject!Text0 = "AA0000"
Forms!frmSelectProject!Text2 = "ZZ9999"
Forms!frmSelectProject.Visible = False
.....open the 3rd form

2. Leave the acDialog parameter, pass the two values using the OpenArgs
parameter, and in the OnLoad event of frmSelectProject, set the values and
then hide the form;

In the calling code;
Dim strOA As String

strOA = "AA0000|ZZ9999"
DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit, acDialog, strOA
.....open the 3rd form

In On Load event of frmSelectProject

Dim strOA() As String

strOA = Split(Me.OpenArgs, "|")
If UBound(strOA) > 0 Then
Me.Text0 = strOA(0)
Me.Text2 = strOA(1)
Me.Visible = False
End If

HTH

Andy


HeatherM said:
I have a report that opens three forms in sequence, each
form asking for report criteria. I would like to fill the
boxes of the second form automatically without prompting
for input. I can't cut this step out of the report process
because the criteria are needed for a shared subreport and
I'm not keen on duplicating the subreport for every
possible variation of the main report.

so.....for form [frmSelectProject] I want text box [Text0]
to be AA0000 and text box [Text2] to be ZZ9999, and then
move onto the next form

What do I do after:
DoCmd.OpenForm "frmSelectProject", acNormal, "", "",
acEdit, acDialog


.
 
A

Andy Cole

Glad to be of help

Andy

HeatherM said:
Thanks Andy!
Option 1 worked perfectly

Regards,
Heather
-----Original Message-----
Heather

As you are opening the criteria form in Dialog mode, the user would,
normally, be required to click something to either close/hide the form to
allow execution to return to the calling code. There are 2 possible
approaches;

1. Remove the acDialog parameter and then set the values and (presumably)
hide the criteria Form;

DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit
Forms!frmSelectProject!Text0 = "AA0000"
Forms!frmSelectProject!Text2 = "ZZ9999"
Forms!frmSelectProject.Visible = False
.....open the 3rd form

2. Leave the acDialog parameter, pass the two values using the OpenArgs
parameter, and in the OnLoad event of frmSelectProject, set the values and
then hide the form;

In the calling code;
Dim strOA As String

strOA = "AA0000|ZZ9999"
DoCmd.OpenForm "frmSelectProject", acNormal, "", "", acEdit, acDialog, strOA
.....open the 3rd form

In On Load event of frmSelectProject

Dim strOA() As String

strOA = Split(Me.OpenArgs, "|")
If UBound(strOA) > 0 Then
Me.Text0 = strOA(0)
Me.Text2 = strOA(1)
Me.Visible = False
End If

HTH

Andy


HeatherM said:
I have a report that opens three forms in sequence, each
form asking for report criteria. I would like to fill the
boxes of the second form automatically without prompting
for input. I can't cut this step out of the report process
because the criteria are needed for a shared subreport and
I'm not keen on duplicating the subreport for every
possible variation of the main report.

so.....for form [frmSelectProject] I want text box [Text0]
to be AA0000 and text box [Text2] to be ZZ9999, and then
move onto the next form

What do I do after:
DoCmd.OpenForm "frmSelectProject", acNormal, "", "",
acEdit, acDialog


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top