I currently have an unbound form (parent form) for data entry. And a datasheet subform based on a query that pulls accounts the user needs to work.
My reasoning behind using an unbound form is because the user needs the option to update multiple records at once and I'm unaware of how to do this with a bound form.
I just got done writing the vba to pull individual records and update them but I keep getting two different pop ups. (pictures attached)
Here is the code to pull the record into the unbound form. Located in the datasheet subform.
And here is the code to save any changes the user makes. Located in the unbound form.
Any ideas how to avoid these pop ups? And I'm very open to an alternative way to do this but would like to maintain the functionality of being able to update a single record or multiple records from the same form. I'm new to access and databases in general. I'm use to working within excel.
My reasoning behind using an unbound form is because the user needs the option to update multiple records at once and I'm unaware of how to do this with a bound form.
I just got done writing the vba to pull individual records and update them but I keep getting two different pop ups. (pictures attached)
Here is the code to pull the record into the unbound form. Located in the datasheet subform.
Code:
Private Sub Form_Current()
Dim par As Access.Form, ctl As Access.Control
On Error GoTo ErrorHandler
Set par = Me.Parent
For Each ctl In par.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
If Len(ctl.ControlSource) = 0 And ctl.Tag <> "Search" And ctl.Tag <> "Header" Then
ctl.Value = Me.Recordset.Fields(ctl.Name)
End If
End If
Next
ErrorHandler:
If Err.Number = 2113 Then Exit Sub
End Sub
And here is the code to save any changes the user makes. Located in the unbound form.
Code:
Private Sub cmdSubmit_Click()
Dim rs As DAO.Recordset, ctl As Access.Control
Set rs = Me!subDatasheet.Form.Recordset
With rs
.Edit
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
If Len(ctl.ControlSource) = 0 And ctl.Tag <> "Search" And ctl.Tag <> "Header" Then
rs.Fields(ctl.Name) = ctl.Value
End If
End If
Next
.Update
End With
End Sub
Any ideas how to avoid these pop ups? And I'm very open to an alternative way to do this but would like to maintain the functionality of being able to update a single record or multiple records from the same form. I'm new to access and databases in general. I'm use to working within excel.
Attachments
Last edited: