Transfering Infromation from one Form to another

  • Thread starter Thread starter Brant
  • Start date Start date
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)
 
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 matching record. If no record is found then you could open the new form with the particular information you want to pass.

Set db = CurrentDb()
'Defines a dataset or a replical table and save record from database 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 meets criteria
If .NoMatch = False Then
Dim stLinkCriteria As String

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