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

Enabling Field Form on New Record

Status
Not open for further replies.

MyKidsFirst

Programmer
Oct 16, 2003
7
0
0
US
Hi there. I'm having trouble with enabling fields on a sub form when the user goes to a new record.

The form has several fields disabled to prevent users from accidentally altering existing records. The user has the capability to enable these fields via a check box that asks if they're sure they want to change the field. Once the field selection has changed on an existing record, I then ask the user to confirm via vbOKCancel. If the user cancels the change, the value goes back to the original value and again disables the field. Likewise if they click OK the field is disabled. I don't particuliarly like all of the messages, but that's the way the end-user wants it. These fields also have an "on double click" event that opens a form for data entry and I had to modify the event to "after update" instead of On Change because the Combo box list wouldn't allow the user to type anything without continuously prompting. Yikes. There's also enabling and disabling based on "Apply Filter".


Anyways, I think I have so many instances of enabling and disabling fields that I've inundated myself. The fields need to be enabled on a new record so that the user doesn't have to manually enable each field via the check box(es). I don't know where I should place the code...or if the code is accurate. Do I need to call out a recordset? Here's the lastest attempt.... Help. Thanks a bunch for any advice.


Sub NewRecordMark(frm As Form)
Dim intnewrec As Integer

intnewrec = frm.NewRecord
If intnewrec = True Then

Me.frmLogSub!chkUpdatePatient.SetFocus
Me.frmLogSub!NewProvider.Enabled = True
Me.frmLogSub!Patient.Enabled = True
Me.frmLogSub!NewClient.Enabled = True
Me.frmLogSub!FileNumber.Enabled = True
Me.frmLogSub!Neg.Enabled = True
Me.frmLogSub!Status.Enabled = True
Me.frmLogSub!State.Enabled = True
Else
Me.frmLogSub!chkUpdatePatient.SetFocus
Me.frmLogSub!Provider.Enabled = False
Me.frmLogSub!Client.Enabled = False
Me.frmLogSub!FileNumber.Enabled = False
Me.frmLogSub!Patient.Enabled = False
Me.frmLogSub!Neg.Enabled = False
Me.frmLogSub!Status.Enabled = False
Me.frmLogSub!State.Enabled = False
End If

End Sub



 
Hi

Do not see anything particulary wrong with your code, but a thought to reduce the volume of code, and messages, why not lock the sub form rather than individual controls of the form within the sub form, that way the fields are protected from accedental changes, but can be unlocked with a single click

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for your reply. I truly appreciate it. You gave me some new ideas.

Unfortunately for this subform, I have to lock the individual controls on the form and allow later updates for on other controls. Unless there's another way to do it. In other words the user may have entered the required fields first and later input less important data such as amounts and dates in other fields. The fields that I'm working with need to be locked although filters may need to be applied thus setting the focus on the field control.

I've tried enabling and disabling fields by calling out the specific fields at the form and sub-form level on OnOpen OnActivate, OnCurrent and OnLoad.....using the Me statement (similiar to the code listed in original message). I just can't figure out why it doesn't work other than placing the code on the individual controls' event for all records.

There must be something I'm missing in code, placement of the code, or the specific "event type".

I just know I must be missing something here...

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top