H
Hydra
From a previous question:
I tried your code but when I substituted my table and field names it threw a
type mismatch.
So I stuck in msgBoxes to check all the values. (with My fild and table names)
msgbox (Me!Level3ID)
msgbox (NZ(DMax("[Level3ID]", "[Table3]")
msgbox (Me![Level1ID])
msgbox (Me!Level2ID)
all return the correct values, but the final code:
Me!Level3ID = NZ(DMax("[Level3ID]", "[Table3]", _
Throws a type mismatch. All of the ID fields in the table are number fields.
I had a different version of the same basic approach, and it also threw a
type mismatch.
Any suggestions?
Air code, needs to be adapted to your tablenames and
fieldnames:
Private Sub Form_BeforeInsert(Cancel as Integer)
Me!Level3ID = NZ(DMax("[Level3ID]", "[Table3]", _
"[Level1ID] = " & Me![Level1ID] & _
& " AND Me![Level2ID] = " & Me!Level2ID)) + 1
End Sub
I tried your code but when I substituted my table and field names it threw a
type mismatch.
So I stuck in msgBoxes to check all the values. (with My fild and table names)
msgbox (Me!Level3ID)
msgbox (NZ(DMax("[Level3ID]", "[Table3]")
msgbox (Me![Level1ID])
msgbox (Me!Level2ID)
all return the correct values, but the final code:
Me!Level3ID = NZ(DMax("[Level3ID]", "[Table3]", _
"[Level1ID] = " & Me![Level1ID] & _
& " AND Me![Level2ID] = " & Me!Level2ID)) + 1
Throws a type mismatch. All of the ID fields in the table are number fields.
I had a different version of the same basic approach, and it also threw a
type mismatch.
Any suggestions?