having trouble with a subform

Jon123

Registered User.
Local time
Today, 01:06
Joined
Aug 29, 2003
Messages
668
I have a subform with 4 fields, it is setup as a continous form. I want to make sure that all 4 fields have data before going to the next record. I also want to make sure once the record is entered it can not be edited. So I added a footer with a command button (save) that I have code to check for null's but how can I lock the records once all 4 fields have data
 
Put some validation code in the subforms Before Update event to check for unfilled controls. Put some code in the On Current event of the sub form to lock all controls if not a new record.
 
ok so I have the valaditation code on the before update but the subform still allow me to start a new record before completing the 1st record. How do I prevent this?
 
ok so I have the valaditation code on the before update but the subform still allow me to start a new record before completing the 1st record.
Then your code is not working as it should. Can you show it to us.
 
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Not Nz(Me.description) <> "") Or (Not Nz(Me.serialnumber) <> "") Or (Not Nz(Me.revlevel) <> "") Then
MsgBox "You must enter the serial number and the rev of the part being replaced. If the part does not have either one or both use NA"
Exit Sub
Else
End If
End Sub
 
Try:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  If (Not Nz(Me.description) <> "") Or (Not Nz(Me.serialnumber) <> "") Or (Not      Nz(Me.revlevel) <> "") Then
    MsgBox "You must enter the serial number and the rev of the part being replaced. If the part does not have either one or both use NA"
    Cancel = True

  End If
End Sub
BTY, please use the code tags when posting code.
 
ok that did the trick for entering a complete record. Now how do I keep someone from changing 1 after there entered?

jon
 
Code in the subforms On Current event:
Code:
Me.description.Enabled = Me.NewRecord
Me.serialnumber.Enabled = Me.NewRecord
Me.revlevel.Enabled = Me.NewRecord
 
ok that does lock it down but how does 1 start a new record?
 
Click the "New Record" button at the bottom of the form. Access also moves to a new record by default when you tab out of the last control.
 
awesome, I just need to fine tune things. Its working great

thanks for the help
 

Users who are viewing this thread

Back
Top Bottom