Reputation: 43
I am running into a snag on the code below. When the code runs, values are being placed on "tblPrepayments", with the exception of the AccountID value. The me.cboAccountID.column(2) is on "frmInvoices", which pulls in the AccountID, but displays a clients name for usability reasons.
I don't get any errors, but the value is not pulling into "tblPrepayments". What am I missing? Please let me know if you need additional clarification.
If [Rec'd_Prepayments] <> "0.00" And [Prepayment_Month] <> "" Or [Prepayment_Year] <> "" Then
Dim RecSet As Recordset
Set RecSet = CurrentDb.OpenRecordset("tblPrePayments")
RecSet.AddNew
RecSet![AccountID] = me.cboAccountID.column(2)
RecSet![Prepayment_Month] = "Billing_Month"
RecSet![Prepayment_Year] = "Billing_Year"
RecSet![Rec'd_Prepayment] = "Prepayment1"
RecSet.Update
End If
End Sub
If I run MsgBox me.cboAccountID.column(2)
, I get a run time error '94': Invalid use of Null. If I change the code to Msgbox me.cboAccountID.column(1)
, I get the client's name, not the ID, and subsequently an error for mismatched data types.
Here is the row source for cboAccountID.
SELECT tblClientLists.[AccountID], [tblClientLists].Invoice_To
FROM tblClientLists
ORDER BY [Invoice_To];
Upvotes: 0
Views: 613
Reputation: 3531
combobox values are 0 based, so you're looking for Me.cboAccountID.column(0) or Me.cboAccountID.Value should also work here.
Upvotes: 1