Transfering Infromation from one Form to another

B

Brant

I have a form created where i have customer information and then the
button that opens another form that relates to that customer. what i
want to do is if there is no match, instead of completley opening a new
form, transfering some of the customer information over to the other
form (just because i want to be able to print this form and see whos
form i am working on at that time)
 
J

jbeggie

Bryant,
One of the ways you could get around this in the command button "click
event run a query that search within the recordset to find matchin
record. If no record is found then you could open the new form with th
particular information you want to pass.

Set db = CurrentDb()
'Defines a dataset or a replical table and save record from databas
into it
Set rst = db.OpenRecordset("TableName", dbOpenDynaset)
'query that searches the table for insp number
strCriteria = "[PrimaryKey] = """ & TextBoxFromMainForm & """"

With rst
.FindFirst strCriteria 'Locates the first record in table that meet
criteria
If .NoMatch = False Then
Dim stLinkCriteria As String

DoCmd.OpenForm "NameOfNewFormToOpen", , , stLinkCriteria
'Adds the following text fields from "form 11" to the "ad
ingredients" form
Forms![NameOfNewFormToOpen].TextBoxName
OldFormTextBoxName
end if
end wit
 
Top