Hi all, I hope that someone can help me. I have a database that is mostly run by macros. I am now attempting to convert the macros to code, so that I can add error handling. Most of the smaller macros I have been able to change simply by resaving them as a module and then pasting them into the forms. Now I have run into some that are more complicated and they are resisting the transistion.
I have a form where you add new customers. On top of the form is combo boxes where you can look up to see if the company already exists in the database. If it does, you see the company information on another form that pops up. You can push the button to have the data on the one form transfer to the other form. It works as a macro, but when turned to code, it doesn't work. If anyone would like to help, the code is pasted below:
Function mcrCopyingCustInfo()
If (Eval("[Forms]![frmEnter Customers]![Company Name] Is Null")) Then
Forms![frmEnter Customers]![Company Name]
= Forms!frmCustomerForCopying![Company Name]
End If
If (Eval("[Forms]![frmEnter Customers]![Address] Is Null")) Then
Forms![frmEnter Customers]!Address
= Forms!frmCustomerForCopying!Address
End If
If (Eval("[Forms]![frmEnter Customers]![2nd Address] Is Null")) Then
Forms![frmEnter Customers]![2nd Address]
= Forms!frmCustomerForCopying![2nd Address]
End If
If (Eval("[Forms]![frmEnter Customers]![City] Is Null")) Then
Forms![frmEnter Customers]!City
= Forms!frmCustomerForCopying!City
End If
If (Eval("[Forms]![frmEnter Customers]![State] Is Null")) Then
Forms![frmEnter Customers]!State
= Forms!frmCustomerForCopying!State
End If
If (Eval("[Forms]![frmEnter Customers]![Zip Code] Is Null")) Then
Forms![frmEnter Customers]![Zip Code]
= Forms!frmCustomerForCopying![Zip Code]
End If
If (Eval("[Forms]![frmEnter Customers]![Phone Number] Is Null")) Then
Forms![frmEnter Customers]![Phone Number]
= Forms!frmCustomerForCopying![Phone Number]
End If
If (Eval("[Forms]![frmEnter Customers]![Fax Number] Is Null")) Then
Forms![frmEnter Customers]![Fax Number]
= Forms!frmCustomerForCopying![Fax Number]
End If
DoCmd.Close acForm, "frmCustomerForCopying"
DoCmd.GoToControl "Contact Full Name"
End Function
If anyone knows why this doesn't work, please help me!!
Thanks
DAKCG
I have a form where you add new customers. On top of the form is combo boxes where you can look up to see if the company already exists in the database. If it does, you see the company information on another form that pops up. You can push the button to have the data on the one form transfer to the other form. It works as a macro, but when turned to code, it doesn't work. If anyone would like to help, the code is pasted below:
Function mcrCopyingCustInfo()
If (Eval("[Forms]![frmEnter Customers]![Company Name] Is Null")) Then
Forms![frmEnter Customers]![Company Name]
= Forms!frmCustomerForCopying![Company Name]
End If
If (Eval("[Forms]![frmEnter Customers]![Address] Is Null")) Then
Forms![frmEnter Customers]!Address
= Forms!frmCustomerForCopying!Address
End If
If (Eval("[Forms]![frmEnter Customers]![2nd Address] Is Null")) Then
Forms![frmEnter Customers]![2nd Address]
= Forms!frmCustomerForCopying![2nd Address]
End If
If (Eval("[Forms]![frmEnter Customers]![City] Is Null")) Then
Forms![frmEnter Customers]!City
= Forms!frmCustomerForCopying!City
End If
If (Eval("[Forms]![frmEnter Customers]![State] Is Null")) Then
Forms![frmEnter Customers]!State
= Forms!frmCustomerForCopying!State
End If
If (Eval("[Forms]![frmEnter Customers]![Zip Code] Is Null")) Then
Forms![frmEnter Customers]![Zip Code]
= Forms!frmCustomerForCopying![Zip Code]
End If
If (Eval("[Forms]![frmEnter Customers]![Phone Number] Is Null")) Then
Forms![frmEnter Customers]![Phone Number]
= Forms!frmCustomerForCopying![Phone Number]
End If
If (Eval("[Forms]![frmEnter Customers]![Fax Number] Is Null")) Then
Forms![frmEnter Customers]![Fax Number]
= Forms!frmCustomerForCopying![Fax Number]
End If
DoCmd.Close acForm, "frmCustomerForCopying"
DoCmd.GoToControl "Contact Full Name"
End Function
If anyone knows why this doesn't work, please help me!!
Thanks
DAKCG