Per gmazza:
>'CurrentProject.Execute "Insert into TransactionHistory values(FirstName,
LastName, LastPaymentDate, LastPaymentAmount)", dbFailOnError
This is strictly a knee-jerk reaction... but it seems like the
query needs to know both the value tb inserted and the name of
the field the value goes into.
When I do something like that, it's more in the form of:
------------------------------------------------------------------
Private Sub cmdAdd_Click()
1000 debugStackPush Me.Name & ": cmdAdd_Click"
1001 On Error GoTo cmdAdd_Click_err
' PURPOSE: To add a new record to the table in question after
computing
' the next available CollateralManagerID
'
' NOTES: 1) FormOpen routine sets gModalAddDialogOutcome
semaphore=FALSE,
' we set it to TRUE to tell calling routine that
the add succeeded.
1002 Dim myQuery As DAO.QueryDef
Dim myUserID As String
Dim myNewRecordID As Long
1010 myUserID = CurrentUserGet()
1019 myNewRecordID = IdGetNext_CollateralManager()
1020 Set myQuery =
CurrentDb.QueryDefs("qryAddRec_CollateralManager")
1030 With myQuery
1031 .Parameters("theRecordID") = myNewRecordID
1032 .Parameters("theName") = Me.txtName
1033 .Parameters("theStreetAddress") = Me.txtStreetAddress
1034 .Parameters("theCity") = Me.txtCity
1035 .Parameters("theState") = Me.cboState
1039 .Parameters("theZip") = Me.txtZip
1040 .Parameters("theCountry") = Me.cboCountry
1041 .Parameters("theComments") = Me.txtComments
1042 .Parameters("theUserID") = myUserID
1043 .Parameters("theTimeStamp") = Now()
1044 .Execute dbFailOnError
1049 End With
1990 gModalDialogOutcome = True
1991 Me.Visible = False
1992 MsgBox "'" & Me.txtName & "' Added", 0, "Done!"
1999 DoCmd.Close acForm, Me.Name
cmdAdd_Click_xit:
DebugStackPop
On Error Resume Next
Set myQuery = Nothing
Exit Sub
cmdAdd_Click_err:
If Err = gError_DuplicateValue Then
MsgBox "That name already exists", 48, "Cannot Add Duplicate"
Else
BugAlert True, ""
End If
Resume cmdAdd_Click_xit
End Sub
------------------------------------------------------------------
Where qryAddRec_CollateralManager looks like this:
------------------------------------------------------------------
PARAMETERS
theName Text ( 255 ),
theStreetAddress Text ( 255 ),
theCity Text ( 255 ),
theState Text ( 255 ),
theZip Text ( 255 ),
theCountry Text ( 255 ),
theComments Text ( 255 ),
theUserID Text ( 255 ),
theTimeStamp DateTime,
theRecordID Long;
INSERT INTO tlkpCollateralManager
(
CollateralManagerID,
CollateralManagerName,
StreetAddress, City,
State,
Zip,
Country,
Comments,
CreatedBy,
CreatedAt
)
SELECT
[theRecordID] AS Expr10,
[theName] AS Expr9,
[theStreetAddress] AS Expr1,
[theCity] AS Expr2,
[theState] AS Expr3,
[theZip] AS Expr4,
[theCountry] AS Expr5,
[theComments] AS Expr6,
[theUserID] AS Expr7,
[theTimestamp] AS Expr8;
------------------------------------------------------------------
--
PeteCresswell