tklingborg
New Member
- Joined
- Jan 30, 2016
- Messages
- 3
Hi I'm trying to pass some values from a form where someone can select a customer. I'm trying to make it possible to select a customer and pass the information in that form to another form.
This is what I've got so far, but I can't get it to work.
Code to open customer select form and pass if it is as sender I want to import the customer:
Code to open customer select form and pass if it is as recipient I want to import the customer:
Code to pass information from customer select form to waybill form based on wether it's for sender or reciever:
Code to enter the passed information in waybill form:
Any thoughts or ideas are welcome
This is what I've got so far, but I can't get it to work.
Code to open customer select form and pass if it is as sender I want to import the customer:
Code:
Private Sub cmdSearchConsignor_Click()
DoCmd.OpenForm FormName:="frmCustomerSelect", View:=acNormal, Datamode:=acFormReadOnly, WindowMode:=acDialog
TempVars.Add "TempSendRecieve", "Consignor"
End Sub
Code to open customer select form and pass if it is as recipient I want to import the customer:
Code:
Private Sub cmdSearchConsignee_Click()
DoCmd.OpenForm FormName:="frmCustomerSelect", View:=acNormal, Datamode:=acFormReadOnly, WindowMode:=acDialog
TempVars.Add "TempSendRecieve", "Consignee"
End Sub
Code to pass information from customer select form to waybill form based on wether it's for sender or reciever:
Code:
Private Sub cmdSelect_Click()
If Not IsNull(TempVars!TempSendRecieve) Then
If TempVars!TempSendRecieve = "Consignor" Then
TempVars.Add "tempConsignorName", Me.txtCustomerName.Value
TempVars.Add "tempConsignorAddress", Me.txtAddress1.Value
TempVars.Add "tempConsignorAddress2", Me.txtAddress2.Value
TempVars.Add "tempConsignorZIP", Me.txtZIP.Value
TempVars.Add "tempConsignorCity", Me.txtCity.Value
TempVars.Add "tempConsignor_Customer_Number", Me.txtCustomerNumber.Value
TempVars.Add "tempContract_Of_Carriage", Me.txtContract_Of_Carriage.Value
TempVars.Add "tempConsignor_Phone_Fax", Me.txtPhone_Fax.Value
DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name, Save:=acSaveNo
ElseIf TempVars!TempSendRecieve = "Consignee" Then
TempVars.Add "tempConsigneeName", Me.txtCustomerName.Value
TempVars.Add "tempConsigneeAddress", Me.txtAddress1.Value
TempVars.Add "tempConsigneeAddress2", Me.txtAddress2.Value
TempVars.Add "tempConsigneeZIP", Me.txtZIP.Value
TempVars.Add "tempConsigneeCity", Me.txtCity.Value
TempVars.Add "tempConsignee_Customer_Number", Me.txtCustomerNumber.Value
DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name, Save:=acSaveNo
Else
MsgBox "Some message", vbOKOnly, "Message"
End If
End If
End Sub
Code to enter the passed information in waybill form:
Code:
Private Sub Form_GotFocus()
If Not IsNull(TempVars!TempSendRecieve) Then
If TempVars!TempSendRecieve = "Consignor" Then
Me.txtConsignor_Customer_Number.Value = TempVars!tempConsignor_Customer_Number.Value
Me.txtConsignor.Value = TempVars!tempConsignorName.Value
Me.txtConsignor2.Value = TempVars!tempConsignorAddress
Me.txtConsignor3.Value = TempVars!tempConsignorAddress2
Me.txtPlace_Of_Dispatch.Value = TempVars!tempConsignorZIP & " " & TempVarsConsignorCity
Me.txtConsignor_Pays_Code.Value = TempVars!tempConsignor_Phone_Fax
TempVars.Remove "TempSendRecieve"
End If
If TempVars!TempSendRecieve = "Consignee" Then
Me.txtConsignee_Customer_Number.Value = TempVars!tempConsignee_Customer_Number
Me.txtConsignee.Value = TempVars!tempConsigneeName
Me.txtConsignee2.Value = TempVars!tempConsigneeAddress
Me.txtConsignee3.Value = TempVars!tempConsigneeAddress2
Me.txtConsignee4.Value = TempVars!tempConsigneeZIP & " " & TempVars!tempConsigneeCity
Me.txtPlace_Of_Discharge.Value = TempVars!tempConsigneeZIP & " " & TempVars!tempConsigneeCity
TempVars.Remove "TempSendRecieve"
End If
End If
End Sub
Any thoughts or ideas are welcome