Thanks for the help lads - Fixed it, basically vba won't allow you to open forms in modules unless they're named - So I open the form before the function, ran the function then closed it like this:
Code:
Private Sub cmdsalesbyadd_Click()
DoCmd.OpenForm ("frmsalesbyadd")
Call addition(Me, [Forms]!frmsalesbyadd)
For Each frm In Forms
If Not frm.Name = "frmsalesbyadd" Then
DoCmd.Close acForm, frm.Name
End If
Next frm
End Sub
Function:
Code:
Sub addition(theform As Form, form2 As Form)
If Not theform.salesnumber.Value = vbNullString Then
Dim salenumber As String
salenumber = theform.salesnumber.Value
form2.lblback.Visible = True
form2.lblnew.Visible = False
Else
salenumber = ""
form2.lblback.Visible = False
form2.lblnew.Visible = True
End If
form2.txtreturn.Value = salenumber
End Sub