S
scadav
Hi,
I have a problem that I am hoping someone can help me with.
I tried searching for a solution to this problem, but could not come up
with one. Anyway, I have button in access that opens a form and adds a
new record, see code below:
stDocName = "Jobs_Progress_AddEdit"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Add a new record
DoCmd.GoToRecord , , acNewRec
Forms!Jobs_Progress_AddEdit.cb_job_id = Me.txt_job_id
Forms!Jobs_Progress_AddEdit.txt_worker_pay_rate = dWorkerRate
Forms!Jobs_Progress_AddEdit.txt_supervisor_pay_rate = dSupervisorRate
The form that this opens is not only for adding new records, but a user
can click on an existing record open this form and edit the data (same
exact form).
In some situations, I do not want the user to edit the data, therefore I
enable/disable certain controls on startup, see code below.
Private Sub Form_Current()
Dim ctl As Control
If (Forms!Jobs_Details.cb_status = 1) Or Not IsNull
(Me.txt_applied_invoice_date) Then
For Each ctl In Me.Controls
If ctl.Tag = "disable_1" Then ctl.Enabled = False
Next
Me.bt_Delete.Enabled = False
End If
End Sub
It appears that the first record, in the table I am trying to create a
new record for, meets the criteria to disable the fields when the form is
opened. Once I hit this code, it disables all the fields in my form,
then creates a new record. Now I can't edit the fields I need to when
creating a new record. So the flow looks something like this.
Step 1. In Form A, Users Hits Add Record Button which he is hoping to
put a new value in table X
Step 2. Form B gets launched and brings up the first record in table X
(I guess by default).
Step 3. The Form_Current code gets run (which I really don't want it to
do when the user hits the add new record button)
Step 4. The Form_Current Form has yet to hit the add new record code, so
it is currently on the first record.
Step 5. The code disables the fields I need the user to input.
Step 6. The New record code runs, but all the fields are disabled.
I guess I could make these two separate forms, but I don't see what I
should do that give it’s the exact same data.
I am thinking I need to do 1 of two things....
1. Once the new record gets created Run the Form_Current code again (not
ideal).
2. Don't run the Form_Current code when creating a new record.
Thanks in advance
I have a problem that I am hoping someone can help me with.
I tried searching for a solution to this problem, but could not come up
with one. Anyway, I have button in access that opens a form and adds a
new record, see code below:
stDocName = "Jobs_Progress_AddEdit"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'Add a new record
DoCmd.GoToRecord , , acNewRec
Forms!Jobs_Progress_AddEdit.cb_job_id = Me.txt_job_id
Forms!Jobs_Progress_AddEdit.txt_worker_pay_rate = dWorkerRate
Forms!Jobs_Progress_AddEdit.txt_supervisor_pay_rate = dSupervisorRate
The form that this opens is not only for adding new records, but a user
can click on an existing record open this form and edit the data (same
exact form).
In some situations, I do not want the user to edit the data, therefore I
enable/disable certain controls on startup, see code below.
Private Sub Form_Current()
Dim ctl As Control
If (Forms!Jobs_Details.cb_status = 1) Or Not IsNull
(Me.txt_applied_invoice_date) Then
For Each ctl In Me.Controls
If ctl.Tag = "disable_1" Then ctl.Enabled = False
Next
Me.bt_Delete.Enabled = False
End If
End Sub
It appears that the first record, in the table I am trying to create a
new record for, meets the criteria to disable the fields when the form is
opened. Once I hit this code, it disables all the fields in my form,
then creates a new record. Now I can't edit the fields I need to when
creating a new record. So the flow looks something like this.
Step 1. In Form A, Users Hits Add Record Button which he is hoping to
put a new value in table X
Step 2. Form B gets launched and brings up the first record in table X
(I guess by default).
Step 3. The Form_Current code gets run (which I really don't want it to
do when the user hits the add new record button)
Step 4. The Form_Current Form has yet to hit the add new record code, so
it is currently on the first record.
Step 5. The code disables the fields I need the user to input.
Step 6. The New record code runs, but all the fields are disabled.
I guess I could make these two separate forms, but I don't see what I
should do that give it’s the exact same data.
I am thinking I need to do 1 of two things....
1. Once the new record gets created Run the Form_Current code again (not
ideal).
2. Don't run the Form_Current code when creating a new record.
Thanks in advance