Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show subform when there's no record

Status
Not open for further replies.

asramala

Technical User
Sep 11, 2001
7
US
Hi--I have a subform on a page that is is read-only (I set the "allow edits" property for the form to "no"). When there is no "sub-data" for the main record, I still want the form to show up with blank fields. Right now, the subform doesn't even show up--just background color of the page. The subform seems to be working properly--it shows up with the correct data when there is a sub-data for the record.

How can I get the subform to show all the time in read-only mode?

Thanks!
 
you could try this

Dim rs As Recordset
Dim CtlType As Variant
Set rs = Me.Recordset.Clone

rs.MoveFirst
If IsNull(rs.Fields(0).Value) Then
Me.DataEntry = True
End If

For Each CtlType In Me
If (CtlType.Tag = "Text") Then
CtlType.Enabled = False
CtlType.Locked = True
End If
Next CtlType

rs.Close
Set rs = Nothing

This would be placed in the OnCurrent Event of the Subform and the Subform Data Entry is Marked No in the properties pages.

This will check to see if there is a value in your first row and your first column. if there is nothing there then it will come up with a blank SubForm that can't be edited.

NOTE: You Must mark each text box tag properties as Text for this to work. If Not the new blank record would be able to be edited

HTH

Email: DSherer@Adatae.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top