Results 1 to 11 of 11
  1. #1
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368

    Refreshing values on main form after closing pop-up form

    Guys,

    If i use a pop-up form to create a file and i return back to the main form, the main form
    will not show that there is an extra file created. Even though the code that calculates the number of
    files is in the Form_Current event.

    When Form_Current fails, the next logical thing would be the Form_GotFocus event.
    But...that fails too.
    Basicly i have tried almost everything but to no avail.

    I have considered Form_timer but it would be rediculous to have to do it that way.



    Any ideas would be great !

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could change Private to Public on the Form_Current event and call it from the Pop-Up form. You would call it like this ...
    Code:
    Forms!FormName.Form_Current
    I usually use the .Dirty property to save the record when using PopUps. But if there is special code that needs to run, you can copy the code and place it in additional modules or you can place the code somewhere accessible from multiple locations.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Do you mean 'create a record'?

    Another approach is to open the popup with acDialog parameter. This suspends code execution from the calling form until the popup closes.

    DoCmd.OpenForm "form name", , , , , acDialog
    Me.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Hey guys,

    ive tried your comments but i still cant get it to work.
    Ive made my form_current event on the main form a public sub and also tried to open the pop-up form in acDialog mode.
    The control (actually a button's caption) on the main form only refreshes when i use my filter again (look up that specific record).

    Ill explain more about what the feature on my form is :

    I have a button called "Agenda" and when clicked opens up a pop-up form. User enters some values (date, time, topic, remarks) and upon clicking a button the code sets an Outlook reminder in its agenda.
    When the Outlook reminder was set, the pop-up form closes.
    The button's caption that was clicked to open the pop-up form should now be "Agenda (1)" to notify users that for the record on the main form an Outlook reminder was made.

    Click image for larger version. 

Name:	AccessForums.jpg 
Views:	24 
Size:	254.5 KB 
ID:	22103

    And then when the reminder was set this code in my Form_Current's event should fire (but it doesnt)
    Code:
        Dim lngRed As Long
        Dim lngBlack As Long
        lngRed = RGB(255, 0, 0)
        lngBlack = RGB(0, 0, 0)
        
        If DLookup("DatumHerinnering", "tblObjecten3", "ObjectID = fldObjectID") >= Date Then
        Me.knpHerinnering.Caption = "Agenda   (1)"
        Me.knpHerinnering.ForeColor = lngRed
        Else
        Me.knpHerinnering.Caption = "Agenda   (0)"
        Me.knpHerinnering.ForeColor = lngBlack
        End If
    When closing the pop-up form the "Agenda (0)" should be replaced by "Agenda (1)"

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Changing the button caption is a design change. The form would have to be saved with this modification if you want it to show this revised caption next time form opens. Otherwise, save value to a table and populate a textbox by binding it to the field or doing a DLookup.

    Current event only fires when first moving to a record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Thanks for the reply June,

    The problem is that if i would bind the "0" or "1" on the button to a textbox (transparent background), the button would not be clickable where the 0 or 1 would be displayed.
    I could of course double code the click event on the textbox, but i dont like that approach.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Could use the value in table to set the button Caption property in Open or Current event. Save the value and set the caption property in the procedure that creates the Outlook reminder.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Hey June,

    Ive tried making a textbox to look like a button and that does work but the button looks different then the other buttons on my form.
    Also tried making the textbox transparent but that has its issues as well.

    I decided to leave it as is, i blame Access for not making the buttons caption editable as you stated

    Thanks for the help mate, i appreciate it as always !

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The caption is programmatically editable. The issue is having the 0 or 1 value available to set the caption. This value must be stored somewhere. A table record is the best place.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Right, im gonna give it one more go. Ill keep you posted !

  11. #11
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    We did it !

    Setting form_current to Public sub was a great idea. Now i can refer to the main form from a pop-up form.
    Made a textbox that holds the complete value i want in the caption of the button, stored it in my main table.
    Looks great too, because as soon as i hit the "delete" button from the pop-up form i see the value on the main form changing. I use the code below to change the caption (changed some names to English for future visitors of this thread).

    Code:
    Forms![frmObjects]![btnAgenda].Caption = Forms![frmObjects]!fldAgendaYesNo.Value
    Thanks for this June !

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-26-2015, 08:05 AM
  2. Replies: 1
    Last Post: 01-31-2015, 09:03 PM
  3. Replies: 6
    Last Post: 01-06-2015, 12:37 PM
  4. Replies: 4
    Last Post: 01-06-2015, 10:03 AM
  5. Replies: 10
    Last Post: 11-19-2012, 10:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums