ItemData combo box problem (Access 2000) (1 Viewer)

I

ilkglass

Guest
The lines of code at the end of this thread were used in an Access 97 database to automatically select an item in a combo box based on the item selected in a different combo box. For example, after Glass1Type has been updated, the code requeries Glass1Name and inserts a value into the Glass1Name combo box based on the case statement.

The problem lines have been commented out, and appear immediately below 'PROBLEM LINE BELOW'. The code appears unable to select a default value in a second combo box Glass1Thickness. I imagine that this problem is a consequence of the relationships. Glass1Type is a one-to-many Glass1Name which is a one-to-many Glass1Thickness.

When the code runs without the lines commented, I get the following message;

"Run-time error '-2147352567' (80020009)': The field 'tblOrderDetails.Glass1Thickness' cannot contain a Null Value because the Required property for this field is set to True. Enter a value in this field."

Interestingly, the code is able to set the first value correctly in the Glass1Name combo box.

I never had this problem until converting my database from Access 97 to Access 2000.

Thanks in advance for any suggestions.

Dan

------------CODE APPEARS BELOW ---------------------

Private Sub Glass1Type_AfterUpdate()

Me.frmSizes.Enabled = True

Me.cmdNextOrdDt.Enabled = True

Glass1Name.Requery

Select Case Glass1Type

Case 1 To 2

Glass1Name = Glass1Name.ItemData(6)
Glass1Thickness.Requery
'PROBLEM LINE BELOW
'Glass1Thickness = Glass1Thickness.ItemData(3)
Glass2Type = Glass1Type
Glass2Name.Requery
Glass2Name = Glass2Name.ItemData(6)
Glass2Thickness.Requery
'PROBLEM LINE BELOW
'Glass2Thickness = Glass2Thickness.ItemData(3)

Case 3

Glass1Name = Glass1Name.ItemData(2)
Glass1Thickness.Requery
'PROBLEM LINE BELOW
'Glass1Thickness = Glass1Thickness.ItemData(3)
Glass2Type = Glass1Type
Glass2Name.Requery
Glass2Name = Glass2Name.ItemData(2)
Glass2Thickness.Requery
'PROBLEM LINE BELOW
'Glass2Thickness = Glass2Thickness.ItemData(3)

Case 4

Glass1Name = Glass1Name.ItemData(1)
Glass1Thickness.Requery
'PROBLEM LINE BELOW
'Glass1Thickness = Glass1Thickness.ItemData(0)
Glass2Type = 3
Glass2Name.Requery
Glass2Name = Glass2Name.ItemData(2)
Glass2Thickness.Requery
'PROBLEM LINE BELOW
'Glass2Thickness = Glass2Thickness.ItemData(3)

End Select

End Sub
 

Users who are viewing this thread

Top Bottom