Thanks, I try to change the name in my query to DCount and I got this in my error compile: "Argument not optional".
I am not sure what to do with your second sugestion.
let me put my code here:
Private Sub Move_Click()
With CodeContextObject
DoCmd.Echo True, "running"
DoCmd.OpenQuery "Look dbl rec", acNormal, acEdit
If (Forms!DIE_FORM!dif1 < 0) Then
Beep
MsgBox "Can not move", vbOKOnly, "BAD MOVE"
If (Forms!DIE_FORM!dif1 = 0) Then
If (DCount = 0) Then
' MsgBox Format(Forms!DIE_FORM!dif1), 0, "Debug Move Button"
' MsgBox "I am here1", 0, "status"
DoCmd.OpenQuery "Update loc", acNormal, acEdit
MsgBox "sub=0 count=0", vbOKOnly, "status"
Else
DoCmd.OpenQuery "Update Rec", acNormal, acEdit
DoCmd.OpenQuery "DELREC", acNormal, acEdit
MsgBox "sub=0 count>0", vbOKOnly, "status"
'MsgBox Format(Forms!DIE_FORM!dif1), 0, "Debug Move Button"
'MsgBox Format(Expr1), 0, "Debug Move Button"
End If
Else
If ([Look dbl rec]![DCount] > 0) Then
DoCmd.OpenQuery "Update Rec", acNormal, acEdit
DoCmd.OpenQuery "DELREC", acNormal, acEdit
MsgBox "sub=0 count>0", vbOKOnly, "status"
'MsgBox Format(Forms!DIE_FORM!dif1), 0, "Debug Move Button"
'MsgBox Format(Expr1), 0, "Debug Move Button"
Else
If ([Look dbl rec]![DCount] = 0) Then
DoCmd.OpenQuery "Update loc", acNormal, acEdit
DoCmd.RunSQL "INSERT INTO DIE_TABLE (DIENAME,COLORS,LENGTH,QUANTITY,LOCATION) VALUES ([DIE_TABLE sub1].Form![DIENAME],[DIE_TABLE sub1].Form![COLORS],[DIE_TABLE sub1].Form![LENGTH],[DIE_TABLE sub1].[qty_in],[DIE_TABLE sub1].Form![loc_in])", -1
MsgBox "sub>0 count=0", vbOKOnly, "status"
Else
'MsgBox "here doing updates", vbOKOnly, "status"
DoCmd.OpenQuery "Update Rec", acNormal, acEdit
DoCmd.OpenQuery "Update Quantity", acNormal, acEdit
MsgBox "sub>0 count>0", vbOKOnly, "status"
End If
End If
DoCmd.OpenForm "DIE_FORM", acNormal, "", "", , acNormal
MsgBox "done", vbOKOnly, "status"
End With
move1_Exit:
Exit Sub
move1_Err:
MsgBox Error$
Resume move1_Exit
End Sub