Re: combine codes



Ahh Marshall,

Sorry for late response but my computer was down. I tried your suggestions
and yes you are so correctl it works the way I wanted it.

Thanks very much.

I posted the following question previously but would like a second opinion
on it.

I have a Main Invoice Form (InvoiceFrm) and Subform (InvoiceDetailsFrm)
The subform which is continuous has a checkbox "Delivered" on each line item
to Make 3 additional fields "Land", "Water", and "Air" Visible/Not Visible.
It works. However instead of showing/hiding only these fields on that
specific line item it show/hide all line items in the subform.

What can I do to fix this please help!


"Marshall Barton" wrote:

Ahh yes, "refresh" the form, not the combo box. In this
case the line of code should be:
Me.Requery

What I had before would just "refresh" the combo box, which
wasn't what you wanted. Sorry if the right answer is even
shorter than the wrong answer ;-)

Note that the wizard generated code is really only doing
that one thing. The rest of the code was just the standard
error handling code that should be included in every
procedure.

The Requery method reloads all of the form's data from its
record source query. Refresh only checks if any of the
form's records were modified by another user. Modified
records will be refreshed, deleted records will show in the
form as "Deleted", but new records will not be included in
the refreshed dataset. Bottom line, Refresh is rarely
useful. OTOH, Requery is very popular, especially if the
form's record source query's criteria is changed (which I
suspect is the purpose of the combo box).
--
Marsh
MVP [MS Access]


Levans digital wrote:\
Yes that code is to refresh the FORM once the "Location" combo has been
updated.
Is refresh and requety the same?

So I can replace all that refresh code with the short requery code?

"Marshall Barton" wrote:

Levans digital wrote:

Code (1) Created by wizard to refresh the “Location” combobox
Private Sub Location_AfterUpdate()
On Error GoTo Err_Refresh__Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_Refresh__Click:
Exit Sub

Err_Refresh__Click:
MsgBox Err.Description
Resume Exit_Refresh__Click
End If
End Sub

Code (2)
Private Sub Location_AfterUpdate()
If Not IsNull(Me![Location]) Then
Me![CargoTallyID] = [Forms]![CargoTallyfrm].[CargoTallyID]
ElseIf IsNull(Me![Location]) Then
Me![CargoTallyID] = Null
End If
End Sub

Both these codes work great when used individually, however because the
“Location” afterupdate event will trigger both I need to to combine them into
one please help.


I can't rememberwhat that archaic A2 wizard code is doing, a
"Refresh"?

Although I don't understand why you think you need to
"refresh" the combo box, I think you might want to add:
Me.Location.Requery
to the end of your second procedure.


.



Relevant Pages

  • Re: multiple users - refresh form
    ... Take a look at the Bookmark property in the Help file, ... The only issue I have now is that when it does refresh it unfilters my ... Is there a way I can also have it requery the data based on the combo ... Torefreshthe data displayed on the subform, ...
    (microsoft.public.access.formscoding)
  • Re: Quick Search Combo Box
    ... Thanks for the hint on the location of the macro action, "refresh." ... Private Sub Combo15_AfterUpdate ... Dim rs As Object ... Dim stDocName As String ...
    (microsoft.public.access.forms)
  • Re: Thanks John & Ken
    ... You should not need to use Refresh. ... > Thank you for the information on how to handle the requery, ... > it's the subform that's being requerried, ... > reason I did this is that requerying the [Availability] subform does not ...
    (microsoft.public.access.queries)
  • RE: Refreshing from a sub-form
    ... A couple of things - check your tab order to make sure that when you press ... me.FIELDYOUWANT.setfocus (after the requery calls). ... That might fix you up when calling it from a subform. ... tried both the requery and the Refresh but no luck. ...
    (microsoft.public.access.formscoding)
  • Re: Quick Search Combo Box
    ... I can tell you that "refresh" isn't directly in the ... Private Sub Combo15_AfterUpdate ... Dim rs As Object ... Dim stDocName As String ...
    (microsoft.public.access.forms)

Loading