So I initially had a bunch of concatenated strings with the values in between them (EX "VALUES (' & Me.LOT & "','" & Me.QUANTITY & "',' etc) but I saw Parameters looked a lot cleaner and allowed for the same if not more control.
When I run this code I get an error in the insert into syntax.
Code:
Dim qdf As DAO.QueryDef, strSQL As String strSQL = "PARAMETERS prmLot Text(255), prmQuantityShipped Long, prmLength Long, prmCalcLbsShipped Long, prmDate Date, prmPO Long; "
strSQL = strSQL & "INSERT INTO tblShippingHistory (IdLot, QuantityShipped, Length, CalcLbsShipped, Date, PO) "
strSQL = strSQL & "VALUES ([prmLot] , [prmQuantityShipped], [prmLength], [prmCalcLbsShipped], [prmDate], [prmPO]);"
Debug.Print strSQL
Set qdf = CurrentDb.CreateQueryDef("", strSQL)
' qdf.Parameters!prmHeat = Me.HEAT
' not sure if I can use a with here but wanted to try. Cant even get to it as it errors on Set qdf
With qdf.Parameters
!prmLot = Me.LOT
!prmQuantityShipped = Me.QUANTITY
!prmLength = Me.LENGTH
!prmCalcLbsShipped = FTtoLBS(Me.QUANTITY)
!prmDate = DATE
!prmPO# = Me.MASTER_PO_
End With
I actually couldn't find any examples of Parameters being used with an Insert query when I was googling.
So I'm not sure if they even work together but I don't see why they wouldn't.
The actual goal of this code is to enter some values from 2 different forms into a table that is not the form source.
As always thanks for any help in advance.