DateAdd on form

richardparker

New member
Local time
Tomorrow, 00:18
Joined
Dec 9, 2015
Messages
8
hello,

I'm working on a form where I can register incoming vendor invoices.
The invoices table has a payment term field, an issue date field, a transaction date field and a a due date field.
I have a different table containing the payment terms with [Id], [Name] and [Number of days] the latter being Number data type.
On the form I use a combo box to select the payment term and also I have the [Number of days] as column(2) of this combo box.

What I'm trying to achieve is:
after having entered the Payment term and the Transaction date I'd like the form to automatically 'suggest' a due date by addig the Number of days to the transaction date. Therefore if the due date is indeed the one on the invoice the user only has to hit TAB.

So far what I tried to do is to create an After Update event of the Transaction date with the following code:
Code:
Me.Due_date = DateAdd("d", Me.Paymentterms2column.Column(2), Me.Transaction_date)
However I must've got something wrong because VBA shoves the following error message in my face:
Run-time error: '94'
Invalid use of Null
 
i suggest:
Me.Due_date = DateAdd("d", nz(Me.Paymentterms.Column(2), 0), cdate(Me.Transaction_date))
 

Users who are viewing this thread

Back
Top Bottom