Let's say I have a form with a textbox and a button that requeries a subform.
How can I display a msgbox if there is no data in textbox and cancel the requery procedure ?
Thank you in advance
Let's say I have a form with a textbox and a button that requeries a subform.
How can I display a msgbox if there is no data in textbox and cancel the requery procedure ?
Thank you in advance
What do you have behind the Button now?
The button runs this code on Click:
Code:Private Sub Command12_Click() On Error GoTo Command12_Click_Err DoCmd.OpenQuery "Query1", acViewNormal, acEdit Me.TempTable_subform.Requery Command12_Click_Exit: Exit Sub Command12_Click_Err: MsgBox Error$ Resume Command12_Click_Exit End Sub
You will need to change the code to something like:
Of course you need to use YourTextBox name instead of the one I used.Code:Private Sub Command12_Click() On Error GoTo Command12_Click_Err DoCmd.OpenQuery "Query1", acViewNormal, acEdit If Len(Me.YourTextBox & "") > 0 Then Me.TempTable_subform.Requery End If Command12_Click_Exit: Exit Sub Command12_Click_Err: MsgBox Error$ Resume Command12_Click_Exit End Sub
Can I enter an else if to show a msgbox for the required field?
Of course.