Re: Linked subform not updating
- From: Mary <Mary@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Apr 2009 10:01:03 -0700
I decided to try tab controls for the first time and now have trouble with a
combo box not working. When I open the subform by itself, the combo box finds
the record on that form. When I use the combo box on the tab page, it stays
on the first record, it doesn't update based on the after update event. I
put the subform on the tab page and they are linked by the EventID. Is there
something else I need to do when using tab controls to get the combo box to
work? I have 5 subforms so tab controls would be a nice feature if I can get
them working.
Thanks,
Mary
"Marshall Barton" wrote:
All three values via LinkMaster/Child with no user enter.
data?? That is a different idea, but I don't think a bound
subform is the right way to save audit data.
A common approach it to use unbound controls on the main
form instead of a subform. Then use a little code in the
form's AfterUpdate event to save the audit record. There
are several ways to add a record to a table.
One way is to open a recordset on the table:
Dim rs As Recordset
Dim SQL As String
SQL = "SELECT * FROM [audit table] WHERE keyfield = 0"
Set rs = DbEngine(0)(0).OpenRecordset(SQL, dbOpenDynaset)
rs.AddNew
rs![users ID] = Me.txtUserID
rs![Event ID] = Me.txtEventID
rs![log note] = "Event updated"
rs.Update
rs.Close : Set rs = Nothing
Another way is to use code to construct and execute an
INSERT INTO query.
Dim SQL As String
SQL = "INSERT INTO [audit table] " _
& "([users ID],[Event ID],[log note]) " _
& "VALUES (" & Me.txtUserID & "," & Me.txtEventID _
& ", ""Event updated"")"
DbEngine(0)(0).Execute SQL, dbFailOnError
--
Marsh
MVP [MS Access]
Mary wrote:
I was hoping it would update based on the Child/Master link. How can I make
the subform "dirty" so it saves? I tried requerying the subform but that
didn't do it.
"Marshall Barton" wrote:
Mary wrote:
I'm having trouble getting my subform to retain the values when the main form
is closed.
The main and subforms are linked by the Event ID. The subform displays the
correct Event ID when the main form is being edited. The subform displays
the current users ID, Event ID and a log note "Event updated". I'm expecting
this data to be retained in the Log table, but it's not there after the main
form is closed. What am I missing?
How do those values get to the subform?
If it's via an expression in a subform text box, then it
will never be saved.
If it's via the LinkMaster/Child properties or the text
box's DafaultValue property, they will not be saved until
something happens to make the subform record dirty (e.g.
user enters something in a bound subfoprm control).
- Follow-Ups:
- Re: Linked subform not updating
- From: Marshall Barton
- Re: Linked subform not updating
- References:
- Linked subform not updating
- From: Mary
- Re: Linked subform not updating
- From: Marshall Barton
- Re: Linked subform not updating
- From: Mary
- Re: Linked subform not updating
- From: Marshall Barton
- Linked subform not updating
- Prev by Date: Re: Disabling checkboxes when an "approved" checkbox is checked
- Next by Date: error executing command
- Previous by thread: Re: Linked subform not updating
- Next by thread: Re: Linked subform not updating
- Index(es):
Relevant Pages
|