Hi
i would like to show a msg , when a sub form is empty and not return no data ?
regards
show msg box when form returns no record
-
- BronzeLounger
- Posts: 1227
- Joined: 01 May 2016, 09:58
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: show msg box when form returns no record
You could create a label somewhere on the subform with caption "No Records". Set its Back Style property to Normal and its Visible property to No.
In the On Current event of the subform:
where lblNoRecords is the name of the label
In the On Current event of the subform:
Code: Select all
Private Sub Form_Current()
Me.lblNoRecords.Visible = (Me.RecordsetClone.RecordCount = 0)
End Sub
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1227
- Joined: 01 May 2016, 09:58
Re: show msg box when form returns no record
thank you Hand
i have another question please, i tried to make this label on top of sub form but i couldn't i tried many ways any idea how to make a a label on top of sub form?
regards
i have another question please, i tried to make this label on top of sub form but i couldn't i tried many ways any idea how to make a a label on top of sub form?
regards
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: show msg box when form returns no record
My suggestion was to create the label in the subform itself, for example on its Detail section. If you want the label to be on the main form, the code would have to be different.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1227
- Joined: 01 May 2016, 09:58
Re: show msg box when form returns no record
when i put the lable inside the subform it can cover all the controls except one of the ... I tried all the way but this control comes up on top of the label, that's why i changed the way the first combo box will come over the label always ... any suggestion?
-
- BronzeLounger
- Posts: 1227
- Joined: 01 May 2016, 09:58
Re: show msg box when form returns no record
i found a trick if its ok , i created a tiny text box and make the set focus on form load to that text box ... now the label is cover everything.