M
milwhcky via AccessMonster.com
I have an order form with a combo box which contains a list of customers.
The combo's source is a query which provides an alphabetized list of
customers joined to the orders table.
One of the many columns of the combo box contains the most recent order
number. Each customer has a unique sequence of order numbers, and when the
customer is chosen from the list, the next order number is generated in the
combo's AfterUpdate code. It works fine until I attempt to choose a new
customer, as the previous order number column is empty for that customer.
The original working code:
Dim ctrl As Control
Set ctrl = Me.ActiveControl
Me.[OrderNumber]= Nz((ctrl.Column(23)),0)+1
Column 23 is the most recent order number for that customer. The combo uses
several columns to fill several fields on the form (shipping address fields,
billing address fields, shipping rates, instructions, etc.).
I've tried to write an If Then statement to deal with new customers, but I
keep getting error codes (usually Run-type error '13', type-mismatch).
Dim ctrl As Control
Set ctrl = Me.ActiveControl
If Len(Me.[OrderNumber]) = 0 Then
Me.[OrderNumber] = 10001
' Each customer's order number sequence begins at 10001
Else
Me.[OrderNumber]= Nz((ctrl.Column(23)),0)+1
End If
I've also tried:
If (Me.[OrderNumber]) = ""
and
If IsNull(Me.[OrderNumber]) = True
Also, the OrderNumber field on the Orders table does not have a Default Value
and is a Long Integer.
The combo's source is a query which provides an alphabetized list of
customers joined to the orders table.
One of the many columns of the combo box contains the most recent order
number. Each customer has a unique sequence of order numbers, and when the
customer is chosen from the list, the next order number is generated in the
combo's AfterUpdate code. It works fine until I attempt to choose a new
customer, as the previous order number column is empty for that customer.
The original working code:
Dim ctrl As Control
Set ctrl = Me.ActiveControl
Me.[OrderNumber]= Nz((ctrl.Column(23)),0)+1
Column 23 is the most recent order number for that customer. The combo uses
several columns to fill several fields on the form (shipping address fields,
billing address fields, shipping rates, instructions, etc.).
I've tried to write an If Then statement to deal with new customers, but I
keep getting error codes (usually Run-type error '13', type-mismatch).
Dim ctrl As Control
Set ctrl = Me.ActiveControl
If Len(Me.[OrderNumber]) = 0 Then
Me.[OrderNumber] = 10001
' Each customer's order number sequence begins at 10001
Else
Me.[OrderNumber]= Nz((ctrl.Column(23)),0)+1
End If
I've also tried:
If (Me.[OrderNumber]) = ""
and
If IsNull(Me.[OrderNumber]) = True
Also, the OrderNumber field on the Orders table does not have a Default Value
and is a Long Integer.