Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing all forms in the database.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How does one go about closing all forms in a database at one time? <p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href= Computerwiz Community</a><br>---==============================---<br>
I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
Won't that just totally exit out of Microsoft Access? I need to close all of the forms without exiting the program. THe way I am doing it now is a DoCmd.Close acForm,&quot;thisForm&quot; for each form in the database, with an <br>
On error goto and a Resume next (this just ignores the errors we would get trying to close a non-opened table). This method works, but I was sure there was a better method. <p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href= Computerwiz Community</a><br>---==============================---<br>
I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
Well, I am using an ODBC connection to transfer data from our AS/400 Infinium to our Access db. There are several reasons why I cannot make a live link to the AS/400. <br>
<br>
When I update the tables in the AS/400 I use a macro that basically inputs the data from the AS/400, puts it in a table, deletes the old table then renames the new one to the old tables name. <br>
<br>
Anyway, if someone has a form open, I cannot update the table they are viewing, so I have to somehow exit them out of the database (or the table) in order to update it. This wouldn't be a problem, if everyone would just exit out of the database when leaving for the day, but, unfortunately, too many people just leave the thing open, and thus my update fails. <br>
<br>
I am presently having the database automatically update at 11:58 pm, and the only way I have found to do this is to have a timer event on the main page that basically closes all open forms at that time, so that when the update starts, we will have no one on...<br>
<br>
Can you think of a better way of doing this? I would really love to hear some suggestions.<br>
<br>
<p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href=I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
Use the Forms collection to capture the names then close. Try the following code:<br>
<br>
Function CloseForms() As Boolean<br>
Dim i As Integer<br>
Dim intTabCount As Integer<br>
Dim strFormName(100) As String<br>
<br>
intTabCount = 0<br>
<br>
For i = 0 To Forms.Count - 1<br>
strFormName(i + 1) = Forms(i).Name<br>
intTabCount = intTabCount + 1<br>
Next i<br>
<br>
For i = 1 To intTabCount<br>
DoCmd.Close acForm, strFormName(i)<br>
Next i<br>
<br>
End Function
 
That looks like what I am trying to do, however I couldn't seem to get it to work at all. I keep getting a message that says &quot;The expression you entered has a function name that Microsoft Access can't find&quot; When I use the function in a macro. If I try to use it on a form, it says &quot;Expected Variable or Procedure, not Module&quot; What am I doing wrong? <p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href=I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
At what point are you getting the error?<br>
<br>
Did you put the function in a module? If so, you ought to be able to run the function right from the code window. Try it & see what happens.<br>
<br>
If it works from the code window you can run it from a macro using the RunCode action.<br>
<br>
Good Luck!
 
I put the function in a module, The function runs okay from the code window. But, when I try to do the Macro it tells me Access cannot find the function name. <br>
<br>
I am using the RunCode command, and have CloseForms() for the function name. I even did the lookup so that access automatically put the function name in the action box (so I know I am not mistyping it or anything). This is tooo strange. I have never seen this before. I mean if the function is there, and I can see the function, and ACCESS can even see the function (when I am designing the macro) why on earth would it not be able to find it???? <p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href=I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
Okay. I renamed the function to ClseForms() and that did the trick. I guess CloseForms() is some kind of internal thing?<br>
<br>
Anyway, the module seems to work perfectly! I appreciate your help. Thanks BitBrain <p>John Vogel<br><a href=mailto:john@computerwiz.net>john@computerwiz.net</a><br><a href=I am currently working on It should be LIVE 1/12/00 or before. I would appreciate suggestions, comments and the like. Please go look and help. Thanks.<br>
---========================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top