Re: Linked subform not updating



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).

.



Relevant Pages

  • Re: Primary key ContactID not migrating to subforms
    ... so that I may get the structure working first. ... way down to the last subform and its table). ... not nest tab controls. ... sfrmEstimate with a tab control on it, then drop sfrmEstimate onto the main ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Tab Controls and underlying query criteria
    ... The criteria for each query that is the base for the ... subforms on the tab controls all work when I open the ... Query - it's when I open the subform on the tab control ...
    (microsoft.public.access.forms)
  • Tab Controls and underlying query criteria
    ... I have a form with multiple tab controls ... There is a subform on each tab control - each subform ... criteria to limit the records being displayed - The ... All queries work when the query is run. ...
    (microsoft.public.access.forms)
  • Re: Form Design Recommendation Tab and subforms
    ... information you have on the tab controls, besides the subform, but if there ... I would then create a new subform (create it on the ... The recordsource for the subform is: ... I need to achieve a method of displaying 5 subforms that display only ...
    (microsoft.public.access.forms)
  • HELP! with saving records on forms with subforms
    ... I have an input form that has three tab controls. ... are sub forms based on two other tables. ... The user may not always use the subform. ...
    (microsoft.public.access.forms)