Full Version: Logic/structure question on code behind a form
UtterAccess Forums > Microsoft® Access > Access Forms
jmorton
Maybe I've looked at this too long & my brain has turned to mush.
I have a form selected by a menu button. It's a once-a-month thing that does monthly processing and calls four different functions from the Form_Open event. Each function does some work updating tables and returns a 'Good"/"Bad" indicator to the code in the monthly processing form to say whether it did it's thing OK or not.
In the frm code, I do a MsgBox to ask the user to verify they did a backup - they answer Yes or No. In one of the functions, I MsgBox to display some relevant dates & again ask the user verify everything is cool.
The MsgBox's work fine, but look a little cheesy. What I want to do is put some labels & buttons on the monthly form and show/hide them at the appropriate time.
Showing & enabling things at the appropriate time works fine. However, how do I get the results of the button click events back to the Form_Open code or to the function code?
Otoyed with the idea of having the click events put a value in a hidden field on the Switchboard form, but then how do I get back the starting point in the original form (or function) to interpret whether the user clicked Yes or No?
I'm obviously not organizing this properly.
Jack
Rainlover
Post deleted by Jack Cowley
Jack Cowley
Jack -
I am not totally clear on what you want as far as message boxes are concerned. If you do not like them then create your own slick forms and pop them up instead of using MsgBox.
HAs far as getting values to forms and funtions - it depends on how you have this set up. You can use the OpenArgs argument of the OpenForm method to pass data to a form. You can also use global variables and these will work for you forms as well as your functions. As for you hidden controls on a form you can use them as well. As long as the form with the hidden values is open you can refer to them with:
[Forms]![FormName]![ControlName]
hth,
Jack
Jack Cowley
Rainlover -
That is the point of this post? If you can give me a good reason it will stay, if not it goes...
Jack
jmorton
Des: They're users - of course they lie! The purpose is just to make them think a little.
ack: I can get my messages and buttons displayed just fine. Actually, it looks best to put them at the bottom of the monthly processing form. My problem is that I'm cruisin' thru my code and want to have the user verify something. I format & show a text box and enable buttons Yes and No.
1) how do I 'pause' my code and not go any further until the user clicks something.
2) When they select Yes/No, the code goes off to the Click Event. There I can set a Global variable to an appropriate value.
3) Now when I finish the Click Event code, how to I get back to the spot in my code where I started to ask the user the question in the first place?
I think I have a basic misunderstanding here.
Tomolena
Without seeing your code, I'm not sure how your process works. That aside, I'm understanding that your form does processing during which you want some user input to guide it along the way. I usually employ data input forms opened in dialog mode to do this. Something like this:
CODE
    Dim strFormName As String
nbsp;   Dim varDate As Variant
    strFormName = "frmDateInput"
    strMsg = "What is the date?"
    DoCmd.OpenForm strFormName, acNormal, , , acFormEdit, acDialog, strMsg
    [color="green"]'Your code pauses here until the user dismisses the form  [/color]
    If IsLoaded(strFormName) Then
        varDate = Forms(strFormName).txtDate
        DoCmd.Close acForm, strFormName
    End If

The beauty of this technique is that it is so flexible. You can format the form to collect any information you want. You can use its OpenArgs to pass messages to the user.
Jack Cowley
If you use the acDialog argument to open a form the code will stop until you make a decision and close the form you just opened. For example -

..code...
DoCmd.OpenForm "FormName", , , , , acDialog
...more code to execute when the form closes...

Does that answer your question?

Jack

PS. Getting late in California so it must be VERY late in Indianapolis... You may be up all night but not me!
Rainlover
Jack

With Regard to------------------

Otoyed with the idea of having the click events put a value in a hidden field on the Switchboard form, but then how do I get back the starting point in the original form (or function) to interpret whether the user clicked Yes or No?

--------------------------------------

What I was attempting to say is that the message popping up is a prompt to remind the user to backup the Data Base. If they have backed it up and they answer yes I don't see any advantage of recording the Yes. This is because they could accidentially answer No instead fo Yes or they could simply Lie.

Perhaps my think is a bit weird.

Jack Please delete both of my posts as they may be confusing to the issue and as such Redundant.

Regards
Edited by: Rainlover on Wed Jun 7 23:26:15 EDT 2006.
jmorton
I haven't used this technique before, but I can see lots of applications for it.
That I'm trying to do here though is display a preformatted message and have the user click a button : Yes I agree, or No I don't agree.
I keep wandering off to the click_event & don't know how to get back.
jmorton
Jack: Aha, the acDialog 'thing' is exactly what I wanted. At the two click events, I can set a global variable , close the form and then when the code takes back off again, I can interpret what they did.
I am REALLY trying to learn this stuff, but there is absolutely no training material available. A reference manual of the different syntax would be invaluable - any you would recommend?
Yep it's pretty late here, but I'm one of those crazy nightowl types.
Which side of the Bay are you on. I have a sister in Union City.
A big time thanks ............ Jack
Jack Cowley
I was lucky to start with Access 1 and in those days the had PRINTED MANUALS! Hard to believe, but it was true. It has been downhill ever since as getting information, like you want is a crap shoot at best. I do not know of any books, but I suggest you go to your local bookseller and look at every book they have on Access and pick the one that is a bit more then you know now. If you get one that is not advanced enough you will be wanting more and there won't be anymore.
Y lucky to start with Access 1 and in those days the had PRINTED MANUALS! Hard to believe, but it was true. It has been downhill ever since as getting information, like you want is a crap shoot at best. I do not know of any books, but I suggest you go to your local bookseller and look at every book they have on Access and pick the one that is a bit more then you know now. If you get one that is not advanced enough you will be wanting more and there won't be anymore.
Your sister is south of Oakland and I am north and east of Vallejo in Fairfield. She is about and hour and a half drive from me, maybe a bit more....and a LOT more if it is rush hour....
Good luck with the db and if you have more questions you know where to come for answers!
Jack
Jack Cowley
Des -
I am leaving this post because you made me laught with your use of 'redundant' again... I also think you may have this post confused with another as there has has been no discussion about backing up the db....
Jack
Rainlover
Jack
I am not having a good day. I even had to notify the moderator that I answered an Excel question with len(nz
I think I might have an early day and an early wine. Please delete my Posts.
Cheers
Rainlover
Jack I am going crazy because this was quoted
On the frm code, I do a MsgBox to ask the user to verify they did a backup - they answer Yes or No. In one of the functions, I MsgBox to display some relevant dates & again ask the user verify everything is cool.
Jack Cowley
Des -
think we both had a bad day yesterday. I read the OP 17 times and I missed the line about the backup every time!! Hopefully today will be a better day for me and I hope you will excuse me for being a bit 'over the top'. You are a good fellow and you have my apologies for being out of touch with reality concerning this thread!
Jack
Rainlover
Jack
did not for one moment think you were over the top, and I thank you for your kind words. This Forum is a fantastic place but it does have limitations due to laungauges. You are in the US while I am Down Under. If I were to write in the same way I talked people would have trouble understanding. You use Color I use Colour, You use Maximize I use Maximise. You use August 30th I use 30th August. We now add the fact that some of us are not the best at the written word, especially me, then we can easilly misunderstand the tone of the message.
Then we look at people who's first laungauge is not English, wow the mind boggles. Also the laungauge of Access, Controls not fields or cells etc. List box? Does this mean Combo box?
Any way I will get out of your way for now. I think I might hit the frog and toad and go down to the rubbdy dub for a few foward passes of o me dear. Now translate that one.
Cheers TGIF
Jack Cowley
Des -
OL!!! I have friends in Sydney, Melbourne and, of course, Queensland... Can I go to them for a translation? The fellow in Melbourne speaks that kind of Aussie slang and could translate in a heartbeat, but I am stumped so you will have to give me the translation...
Do not short change yourself as far as your writing ability. You are articulate, have good grammer, syntax and vocabulary. And I am very familiar with colour and using 's' instead of zed, or 'z' as we call it...
Only Thursday here... But when it is Sunday you will be off to work!! It all works out... And it is getting into winter for you and summer for me... Oh my...
I think you can translate this: I am off to the wine cellar....
Jack
Rainlover
The Frog and Toad is the Road.
The Rubbdy Dub is the Pub or Public House.
The Foward Passes is Glasses
The O Me Dear is Beer.
o I am going to hit the road and go to the pub for a few glasses of beer.
Jack Cowley
Des -
AUGHING OUT LOAD! I had a suspicion that it had to do with a pub, but that was all. My friend in Melbourne uses that same slang, but the women in Sydney never use it, but I imagine they can... Thanks for the translation and enjoy your Friday!!! Still laughing out loud.... laugh.gif o!
Jack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.