0
votes

I have some vba in the On Open event of a form, however, when the form is opened, the controls are locked up or frozen. Controls such as buttons are fine, but dropdown boxes, textboxes, etc are 'stuck'. I am able to click them, but the focus and cursor doesnt move to the control. Trying to open a dropdown doesnt engage the control, etc.

I have narrowed it down to the VBA setting the text/value of a textbox. If I comment the lines for changing the value, the form works as intended other than that function. Note that this same VBA code works without issue on another form.

Here is the code currently:

Dim OtherMax As Long
Dim MaterialsMax As Long

OtherMax = DMax("[PO Num]", "[All POs]")
MaterialsMax = DMax("[PO NUMBER]", "[MATERIAL PO DATASHEET]")

DoCmd.GoToRecord , , acNewRec

If IsNull(Me.PONum) Then
    If MaterialsMax >= OtherMax Then
        Me.PONum = MaterialsMax + 1
    Else
        Me.PONum = OtherMax + 1
    End If
End If

What am I doing wrong to cause the controls to lock up?

Thanks in advance, Mike

1

1 Answers

0
votes

Found a solution to my issue:

To work around the On Open event causing the controls to freeze, I moved the function to the On Load function instead. The form still seems to load and work as intended.

Thank everyone who took the time to read/answer the question.