Dear Sir, Please be aware that there is a problem with your code for the workbook called: Customer_Invoicing.xls. When clicking OK on the form “LoadCustomer”, the function “LoadCust” is called as follows with the variable “custid” that is of “string” type.: VBA Code:
Private Sub OK_Click() Application.ScreenUpdating = False Dim custid As String protection.Unprotectit If customer.ListIndex <> -1 Then custid = customer.Value If custid <> "" Then custid = Left(custid, InStr(1, custid, ".") - 1) End If Common.LoadCust (custid) End If Sheets("Invoice").Select protection.Protectit Unload Me Application.ScreenUpdating = True End Sub
Therefore variable in the definition of the function “LoadCust” in the module “Common” should be a “string” and NOT a “single”. I propose the following corrections:
VBA Code:
Function LoadCust(cust As Single As String) ……… ……… If cust > 0 Then cust <> “” then Sheets("Invoice").Select ……… ……… End If If custno > 0 Then Sheets("Invoice").Select Range("custname").Select ActiveCell.Formula = custname ActiveCell.Offset(0, 9).Formula = custno ActiveCell.Offset(1, 0).Formula = compname ActiveCell.Offset(2, 0).Formula = street ActiveCell.Offset(3, 0).Formula = city ActiveCell.Offset(4, 0).Formula = country ActiveCell.Offset(5, 0).Formula = "Phone/Fax: " & phone ActiveCell.Offset(6, 0).Formula = "Email: " & email End If End Function
Thank you for this report. Indeed there is a variable type mismatch in the code for the customer ID. We will look into resolving this; however it does not produce an error as the ID text is interpreted as a number when passed to the loading function.