I use the following code to automatically enter an updated cage number after entering the Class number
Private Sub CageNo_Enter()
On Error GoTo Total_In_Class_Err
' Get ExhibitorID from [Forms]![ Entry Form]![ExhibitorID] and put into [Forms]![Entry Form]![Bird Entry SubForm]![Bird Entry SubForm]![ExhibitorID]
Forms![Entry Form]![Bird Entry SubForm]!ExhibitorID = Forms![Entry Form]!ExhibitorID
' Open Total In Class Form Window mode is Hidden
DoCmd.OpenForm "Total in Class Form", acNormal, "", "", , acHidden
' Get value form [Forms]![Total In Class]![NumberInClass] and put into [Forms]![Entry Form]![Bird Entry SubForm]![CageNo]
Forms![Entry Form]![Bird Entry SubForm]!CageNo = Eval("[Forms]![Total in Class Form]![NumberinClass]")
' Close Total In Class Form
DoCmd.Close acForm, "Total in Class Form"
' Turn off warnings about updating
DoCmd.SetWarnings False
' UpGrade CageNo +1 Query to next cage number
DoCmd.OpenQuery "Update CageNo +1 Query", acViewNormal, acEdit
' Close update Query
DoCmd.Close acQuery, "Update CageNo +1 Query"
Total_In_Class_Exit:
Exit Sub
Total_In_Class_Err:
MsgBox Error$
Resume Total_In_Class_Exit
End Sub
There are gaps in the Class numbers between each Section of birds. If a number that does not exist is entered accidentally I get the Runtime error 3101 (sometimes with the Visual Basic Screen) If I click "End" the message box "The value entered isn't valid for this Field" appears. Click okay in this message box leaves the flashing cursor and the number 0 in the Cage number cell. press ESC and everything returns to normal. I am wondering if any other code could be added to the above that doesn't return the Runtime Error. Just shows the Value entered isn't valid message and asks for the ESC button to be pressed or something similar to make it easier. Thanks
Private Sub CageNo_Enter()
On Error GoTo Total_In_Class_Err
' Get ExhibitorID from [Forms]![ Entry Form]![ExhibitorID] and put into [Forms]![Entry Form]![Bird Entry SubForm]![Bird Entry SubForm]![ExhibitorID]
Forms![Entry Form]![Bird Entry SubForm]!ExhibitorID = Forms![Entry Form]!ExhibitorID
' Open Total In Class Form Window mode is Hidden
DoCmd.OpenForm "Total in Class Form", acNormal, "", "", , acHidden
' Get value form [Forms]![Total In Class]![NumberInClass] and put into [Forms]![Entry Form]![Bird Entry SubForm]![CageNo]
Forms![Entry Form]![Bird Entry SubForm]!CageNo = Eval("[Forms]![Total in Class Form]![NumberinClass]")
' Close Total In Class Form
DoCmd.Close acForm, "Total in Class Form"
' Turn off warnings about updating
DoCmd.SetWarnings False
' UpGrade CageNo +1 Query to next cage number
DoCmd.OpenQuery "Update CageNo +1 Query", acViewNormal, acEdit
' Close update Query
DoCmd.Close acQuery, "Update CageNo +1 Query"
Total_In_Class_Exit:
Exit Sub
Total_In_Class_Err:
MsgBox Error$
Resume Total_In_Class_Exit
End Sub
There are gaps in the Class numbers between each Section of birds. If a number that does not exist is entered accidentally I get the Runtime error 3101 (sometimes with the Visual Basic Screen) If I click "End" the message box "The value entered isn't valid for this Field" appears. Click okay in this message box leaves the flashing cursor and the number 0 in the Cage number cell. press ESC and everything returns to normal. I am wondering if any other code could be added to the above that doesn't return the Runtime Error. Just shows the Value entered isn't valid message and asks for the ESC button to be pressed or something similar to make it easier. Thanks