Lock a field in place for a new records

morlan

Registered User.
Local time
Today, 06:51
Joined
Apr 23, 2003
Messages
143
See my check box 'Lock this value for all new records'?.. well it doesnt actually work.. how can I make it work..? ie: when I select Julie Devenport, enter all details and click 'Add record' that it will stay on Julie Devenport for the next data entry...

db.gif
 
What have you tried to get to checkbox to work? What is the rowsource of the combo box? Is it a bound field?

A simple way would be to have the click event of the Add Record button place the SalesExec value into a variable if the checkbox is checked, go to a new record, then place the SalesExec value into the combo box. You can also disable the combo box so that people can't change the SalesExec chosen unless they uncheck the checkbox.
 
dcx693 said:
What have you tried to get to checkbox to work? What is the rowsource of the combo box? Is it a bound field?

A simple way would be to have the click event of the Add Record button place the SalesExec value into a variable if the checkbox is checked, go to a new record, then place the SalesExec value into the combo box. You can also disable the combo box so that people can't change the SalesExec chosen unless they uncheck the checkbox.

That sounds about right. The check box does nothing at the moment as Im not great on scripting
 
On the AddRecord button you'll want to dimension a variable and get the person's name into this and then (I'm guessing this is pure and simple data entry and moves to a blank record on the same form to be filled in again) and then assign the variabel to the combobox.

Something like this on the button's Click() event.

Code:
Dim varName As Variant
varName = Me.cboYourCombo
Do Cmd.GotoRecord, , acNewRec
If Me.chkYourCheckBox = True Then
    Me.cboYourCombo = varName
End If
 
Mile-O-Phile said:
On the AddRecord button you'll want to dimension a variable and get the person's name into this and then (I'm guessing this is pure and simple data entry and moves to a blank record on the same form to be filled in again) and then assign the variabel to the combobox.

Something like this on the button's Click() event.

Code:
Dim varName As Variant
varName = Me.cboYourCombo
Do Cmd.GotoRecord, , acNewRec
If Me.chkYourCheckBox = True Then
    Me.cboYourCombo = varName
End If

I currently have the following code for the add record button:

Option Compare Database

Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click



End Sub
[/b]
-----
Your code

Dim varName As Variant
varName = Me.SalesExec
DoCmd.GoToRecord , , acNewRec
If Me.chkLock = True Then
Me.SalesExec = varName
End If


When you click on 'add record', the code will look to see if the check box is checked. If checked, it will update the SalesExec drop down in the new record to whatever the value was in the last record. I dont understand how your code will update the SalesExec field in the new record though. How to I incorporate that code in with the Add Record code?
 
Take out the DoCmd.GotoRecord, , acNew of your code and replace it with mine being sure to change any control names I've mentioned to match those of yours.

Then try it.
 

Users who are viewing this thread

Back
Top Bottom