UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Form Refresh, Access 2013    
 
   
tbs
post Jan 12 2018, 11:48 AM
Post#1



Posts: 285
Joined: 12-February 13



Hi -

I am sure this is a quick fix but I am unable to figure this out.

Problem:

- I have a Main form with several sub forms open.
- In one of the sub forms, it is a communication log.
- This communication log subform is locked (cant edit).
- This communication log has a command button to open a new form (call it frm_newCLR) to enter new record in the communication log. The Main form stays open.
- After frm_newCLR is closed, record is appended to the communication log table.

After I close frm_newCLR, I want the Main Form to be Refreshed so that the communication log subform will show the new record entered from frm_newCLR.

I've tried Refresh on:

- On Dirty
- On Got Focus

in the Property Sheet of the subform, but it didn't work.


Go to the top of the page
 
theDBguy
post Jan 12 2018, 12:11 PM
Post#2


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Hi,

How exactly are you opening the "other" form (frm_newCLR)? If you're not using acDialog, then you might try it.

Just a thought...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tbs
post Jan 12 2018, 04:24 PM
Post#3



Posts: 285
Joined: 12-February 13



DBguy,

I'm sure there is a smarter way to do this, but this is how I set it up:

I created a temp table (tblLog_temp) and a blank form (frm_newCLF) that looks like the regular communication log form (and table).

The command button opens frm_newCLF in front of the main form.

User will populate info on frm_newCLF. When done, user will close the form. A VBA is written to close the form, append record from temp table to main table, then empty the temp table. The VBA looks like this:

CODE
On Error GoTo CloseNewLog_Err

    DoCmd.Close acForm, "frm_newCLF"
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "Append_tblLog", acViewNormal, acEdit
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "Delete_tblLog_temp", acViewNormal, acEdit
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdRefreshPage
        

CloseNewLog_Exit:
    Exit Sub

CloseNewLog_Err:
    MsgBox Error$
    Resume CloseNewLog_Exit


What I am missing is the refresh Main form that has the communication log in the subform. I can hit Refresh to get the latest records but I want it be done with VBA. I thought DoCmd.RunCommand acCmdRefreshPage would do that for me.
Go to the top of the page
 
theDBguy
post Jan 14 2018, 10:39 AM
Post#4


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Where is this code you posted located? On the main form?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tbs
post Jan 16 2018, 11:23 AM
Post#5



Posts: 285
Joined: 12-February 13



Sorry I didn't reply back. The email notification was turned off.

Anyway, to answer (DBguy's) question, the code is located on the command button on frm_NewCLF.
Go to the top of the page
 
theDBguy
post Jan 16 2018, 11:38 AM
Post#6


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Thanks. Can you post the code on the main form, which opens frm_NewCLF?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tbs
post Jan 16 2018, 11:53 AM
Post#7



Posts: 285
Joined: 12-February 13



I added: Me.refresh on the frm_newCLR and got this message:

"The expression you entered refers to an object that is closed or doesn't exist."

That's because frm_newCLR. I wanted the me.refresh to refresh the main form.


To answer (DBguy's) question, the main form has a command button behind a macro that OpenForm frm_newCLR.

The property sheet's Event tab has nothing on it.
Go to the top of the page
 
theDBguy
post Jan 16 2018, 11:54 AM
Post#8


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Okay, can you post the macro? Thanks.

I am trying to get you to use the Dialog mode...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tbs
post Jan 16 2018, 02:16 PM
Post#9



Posts: 285
Joined: 12-February 13



Sorry, I was at a meeting. I'm back. This is what it looks like:

Attached File  Capture.JPG ( 33.55K )Number of downloads: 1


Are you saying thee Window Mode should be "Dialog" instead of "Normal"?
Go to the top of the page
 
theDBguy
post Jan 16 2018, 02:24 PM
Post#10


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Yes, that's exactly what I was saying. Then, add an action to Requery the form.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
tbs
post Jan 16 2018, 02:46 PM
Post#11



Posts: 285
Joined: 12-February 13



Still not working. (the refresh main page after I close frm_newCLR).


I think I have an idea... I'm going to shuffle the code in frm_newCLR a little bit. I'll post here if there is success.
Go to the top of the page
 
tbs
post Jan 16 2018, 03:00 PM
Post#12



Posts: 285
Joined: 12-February 13



I guess I found another way that will not work. frown.gif

I am going to create a waterdown db and upload it for you (and others to look). Might be a while before I do that.

Before I do this, is there a way to refresh all open forms before I close frm_newCLR?
Go to the top of the page
 
tbs
post Jan 16 2018, 04:06 PM
Post#13



Posts: 285
Joined: 12-February 13



For now, my workaround to this solution is to put a refresh when you click on the Communication Log subform tab.

At least I can tell my users to click on it to see the updated subform on the main page with the latest record additions.

Go to the top of the page
 
mike60smart
post Jan 16 2018, 04:28 PM
Post#14


UtterAccess VIP
Posts: 12,650
Joined: 6-June 05
From: Dunbar,Scotland


Hi

In the ONClose Event of frm_newCLR you can try thgis:-

Forms![MainForm].[Comms Form].Form.Requery

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tbs
post Jan 16 2018, 04:46 PM
Post#15



Posts: 285
Joined: 12-February 13



I didn't realize you can do that on VBA. It looks like I am close.

I got the run time error '2465' - "cant find the field ' 1' referred to in your expression.
Go to the top of the page
 
tbs
post Jan 16 2018, 04:50 PM
Post#16



Posts: 285
Joined: 12-February 13



Jackpot!

Thank you mike for chiming in.

I used: Forms![Main form].Form.Requery

and it works.

Thank you and DBguy for this great learning experience.
This post has been edited by tbs: Jan 16 2018, 04:50 PM
Go to the top of the page
 
mike60smart
post Jan 16 2018, 04:58 PM
Post#17


UtterAccess VIP
Posts: 12,650
Joined: 6-June 05
From: Dunbar,Scotland


Hi tbs

We were ALL glad to help

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
theDBguy
post Jan 16 2018, 10:29 PM
Post#18


Access Wiki and Forums Moderator
Posts: 72,707
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Glad to hear you got it sorted out. Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th July 2018 - 10:28 PM