open 2 forms with matching text box

  • Thread starter Thread starter a
  • Start date Start date
A

a

I have a form with command button and text box

how can I open another form but with condition textbox is equal in 2 forms
I mean (matching)

by command button on the main form.
 
Hi,
here is an example

DoCmd.OpenForm "frm2ndForm", , , "([VisSiteNo] = " & Me.txtVisSiteNo & ") "

--frm2ndForm is the name of the form to open
--[VisSiteNo] is a number field, if [VisSiteNo] was a text field use
"([VisSiteNo] = """ & Me.txtVisSiteNo & """) "
--txtVisSiteNo is the name of the textbox on the 1st form, [VisSiteNo] is
the primary key in the table for the 1st form
--txtVisSiteNo is also the name of the textbox on the 2nd form, [VisSiteNo]
is the primary key in the table for the 2nd form

Jeanette Cunningham
 
thank you very much
it work very good


Jeanette Cunningham said:
Hi,
here is an example

DoCmd.OpenForm "frm2ndForm", , , "([VisSiteNo] = " & Me.txtVisSiteNo & ")
"

--frm2ndForm is the name of the form to open
--[VisSiteNo] is a number field, if [VisSiteNo] was a text field use
"([VisSiteNo] = """ & Me.txtVisSiteNo & """) "
--txtVisSiteNo is the name of the textbox on the 1st form, [VisSiteNo] is
the primary key in the table for the 1st form
--txtVisSiteNo is also the name of the textbox on the 2nd form,
[VisSiteNo] is the primary key in the table for the 2nd form

Jeanette Cunningham


a said:
I have a form with command button and text box

how can I open another form but with condition textbox is equal in 2
forms I mean (matching)

by command button on the main form.
 
hi
another question please:

If (frm2ndForm) no data match with first form

I want frm2ndform not open or message box (No result)

Thank you for your answer


Jeanette Cunningham said:
Hi,
here is an example

DoCmd.OpenForm "frm2ndForm", , , "([VisSiteNo] = " & Me.txtVisSiteNo & ")
"

--frm2ndForm is the name of the form to open
--[VisSiteNo] is a number field, if [VisSiteNo] was a text field use
"([VisSiteNo] = """ & Me.txtVisSiteNo & """) "
--txtVisSiteNo is the name of the textbox on the 1st form, [VisSiteNo] is
the primary key in the table for the 1st form
--txtVisSiteNo is also the name of the textbox on the 2nd form,
[VisSiteNo] is the primary key in the table for the 2nd form

Jeanette Cunningham


a said:
I have a form with command button and text box

how can I open another form but with condition textbox is equal in 2
forms I mean (matching)

by command button on the main form.
 
Hi,
check the recordsource of frm2ndform to see if it does have that particular
value in its recordsource, and it not, don't open frm2ndform.
Something like this:

If DCount("[VisSiteNo]", "Recordsource of frm2ndform", "[VisSiteNo] = " &
Me.txtVisSiteNo) >0 then
'code here to open frm2ndform
Else
'don't open frm2ndform
'code to show a message if you want to
End If

if txtVisSiteNo has text data then use:
"[VisSiteNo] = ' & Me.txtVisSiteNo '"

"Recordsource of frm2ndform" can be any query that will tell you if the
chosenVisSiteNo is in the recordsource for frm2ndform.

Jeanette Cunningham


a said:
hi
another question please:

If (frm2ndForm) no data match with first form

I want frm2ndform not open or message box (No result)

Thank you for your answer


Jeanette Cunningham said:
Hi,
here is an example

DoCmd.OpenForm "frm2ndForm", , , "([VisSiteNo] = " & Me.txtVisSiteNo & ")
"

--frm2ndForm is the name of the form to open
--[VisSiteNo] is a number field, if [VisSiteNo] was a text field use
"([VisSiteNo] = """ & Me.txtVisSiteNo & """) "
--txtVisSiteNo is the name of the textbox on the 1st form, [VisSiteNo] is
the primary key in the table for the 1st form
--txtVisSiteNo is also the name of the textbox on the 2nd form,
[VisSiteNo] is the primary key in the table for the 2nd form

Jeanette Cunningham


a said:
I have a form with command button and text box

how can I open another form but with condition textbox is equal in 2
forms I mean (matching)

by command button on the main form.
 
Back
Top