I have a query that returns data in a layout similar to what is shown below.
Company |
Form Name |
Receives Form? |
Date Form Complete |
Notes |
Autonum |
ABC Co. |
Form 123 |
Yes |
8/16/2012 |
Faxed copy to client |
1 |
ABC Co. |
Form 456 |
No |
|
|
2 |
ABC Co. |
Form 789 |
No |
|
|
3 |
XYZ Inc. |
Form 123 |
No |
|
|
4 |
XYZ Inc. |
Form 456 |
No |
|
|
5 |
XYZ Inc. |
Form 789 |
Yes |
7/17/2012 |
|
6 |
I am trying to create a dynamic form where users can only update existing records. Essentially, there is a record selection form, where the user will select which client they wish to update (i.e. ABC Co.). I then have VBA code to build the SQL code to select just that client's record from the above query (and that is used as the Control Source of my Form).
So, in the Form Header section of the Form, I just show the Company Name. The other four fields are placed in the Details section (not displaying the Autonum field). Since ABC Co. has three records, there are three records returned in the Detail section.
Now, here comes the tricky part. The "Receives Form?" field is a check box that they can toggle on/off. When it is toggled on, I want it to enable the "Date Form Complete" and "Notes" fields for updating. However, when it is toggled off, I want these two fields to be disabled. And of course, I only want the toggling on/off to affect that particular record. The issue that I am having is that my toggling seems to affect all three records on the Form.
Here is what my VBA code looks like:
Code:
Private Sub Form_Load()
' Run check box defaults
Call Detail_Defaults
End Sub
Private Sub chkReceivesForm_Click()
Call Detail_Defaults
End Sub
Sub Detail_Defaults()
If Me.chkReceivesForm = 0 Then
Me.dteCompletionDate.Enabled = False
Me.strNotes.Enabled = False
Else
Me.dteCompletionDate.Enabled = True
Me.strNotes.Enabled = True
End If
End Sub
Does anyone have any idea how I can modify this so selecting a check box only enables/disables the fields associated with that single record, and doesn't affect the other ones?
Thanks