Sorry about that I figured it out the other day. My program is pretty complex so it gets confusing at times. I'm programming a complete database for a lab with drop down menu selections, bench sheets, records etc. I defined a string
strCustomer well I'll show you my code I got it working most of the way.
Private Sub cmdprint_Click()
On Error GoTo Err_cmdprint_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "tbldate"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acTable, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Text54.Value = Now()
Text54.Visible = True
Exit_cmdprint_Click:
Exit Sub
Err_cmdprint_Click:
MsgBox Err.Description
Resume Exit_cmdprint_Click
End Sub
Private Sub Combo27_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CompanyID] = " & Str(Nz(Me![Combo27], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.Combo29.Requery
Combo29.Visible = True
End Sub
Private Sub Combo27_Change()
cmdprint.Visible = False
Dim strCustomer As String
' define string
strCustomer = strCustomer & "" & Me.Combo27.SelText & ", "
'appending the value to string from box
' remove excess off string in append
strCustomer = Left(strCustomer, Len(strCustomer) - 2)
pass (strCustomer)
End Sub
Private Sub Combo29_AfterUpdate()
cmdprint.Visible = True
End Sub
Private Sub Combo29_Change()
Dim strTest As String ' define string Test to use for append
strTest = strTest & "" & Me.Combo29.SelText & ", " 'append string from combobox
' to remove excess comma stored in append
strTest = Left(strTest, Len(strTest) - 2)
pass2 (strTest)
cmdprint.Visible = True
End Sub
Private Sub Form_Load()
Text54.Visible = False
Combo29.Visible = False
cmdprint.Visible = False
End Sub
Sub pass(x As String)
Dim store As String
store = x
If cmdprint.Visible = True Then
Dim strSQL As String
strSQL = "INSERT INTO TablePrint (CustomerPrint) " & _
"VALUES('" & store & "')"
DoCmd.RunSQL strSQL
DoCmd.GoToRecord , , acNewRec
End If
End Sub
Sub pass2(y As String)
Dim store2 As String
store2 = y
If cmdprint.Visible = True Then
Dim strSQL As String
strSQL = "INSERT INTO TablePrint (CustomerTest) " & _
"VALUES('" & store2 & "')"
DoCmd.RunSQL strSQL
DoCmd.GoToRecord , , acNewRec
End If
End Sub