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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling a subform in Access 2007

Status
Not open for further replies.
Feb 10, 2009
52
US
I have a data entry form with three subforms. The form's fields of name, date, etc. are automatically populated from a table. The three subforms require data entry by the users.

If the user selects a record (on the main form) with an id of zero (meaning no record exists), I would like the three subforms to be disabled so the user cannot key any data into the subform.

If the user selects any other id number, the three subforms will need to allow data entry.

Currently, the subforms allow data entry on a record with an id number of zero, thus introducing erroneous information into my database.

I did not design this database, but I have found some code behind-the-scenes that reads as follows:

Private Sub Combo4_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[KAMISID] = " & Str(Nz(Me![Combo4], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

However, this does not seem to work as the database allows data entry on a record with a id number of zero.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top