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!

Outputting contents of last opened form to file through VBA code.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a combo box that allows a user to run a specific query. The main code look slike this:<br><FONT FACE=monospace><b><br>If Me!Combo2.Text = &quot;QueryName&quot; Then<br>&nbsp;stDocName = &quot;Form that runs query&quot;<br>End If<br><br>DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria<br></b></font><br><br>This opens the form that runs the query. After this is opened, I also have the following line:<br><br><FONT FACE=monospace><b><br>DoCmd.OpenForm &quot;Purchasing Menu&quot;, acNormal<br></b></font><br><br>This form has the following subroutine: <br><FONT FACE=monospace><b><br>DoCmd.OutputTo acOutputForm<br></b></font><br><br>What I would like to do is to output the form that is opened <b><i>before</i></b> the Purchasing Menu. Can someone tell me how to supply or get the name of the last loaded form, so I can set the focus to that using DoCmd.SelectObject acForm, stDocName ? <p>John Vogel<br><a href=mailto:johnvogel@homepage.com>johnvogel@homepage.com</a><br><a href= FreeDSL Service</a><br>[To a get FREE DSL Modem WITH FREE DSL Unlimited Internet Connection click the above link :)]
 
Would I be correct in saying that what you are trying to do is get the name stored in <FONT FACE=monospace><b>stDocName</b></font> to the subroutine of the purchasing menu form, so that it can be output from there?<br><br>If so, you could either supply it to the purchasing menu form using the OpenArgs parameter of <FONT FACE=monospace><b>DoCmd.OpenForm</b></font>.&nbsp;&nbsp;This can then be accessed from the Purchasing menu form using <FONT FACE=monospace><b>Me.OpenArgs</b></font>.<br><br>Hope this helps.
 
I have a table with three text fields. One field holds the username, one holds the date, the other holds the time. I have written a routine which (is supposed to) outputs the values of the the above fields to the UserHistory Table. The Code I am using follows. But this gives me an Error. Any ideas?<br><FONT FACE=monospace><b><br>Private Sub Form_Load()<br>Dim strSQL As String<br>Dim strUserName As String<br><br>strUserName = Environ(&quot;USERNAME&quot;)<br><br>strSQL = &quot;INSERT INTO UserHistory (UserName,Date,Time) VALUES ('&quot; & strUserName & &quot;','&quot; & Date & &quot;','&quot; & Time() & &quot;');&quot;<br><br>DoCmd.RunSQL strSQL<br><br>End Sub<br></b></font> <p>John Vogel<br><a href=mailto:johnvogel@homepage.com>johnvogel@homepage.com</a><br><a href= FreeDSL Service</a><br>[To a get FREE DSL Modem WITH FREE DSL Unlimited Internet Connection click the above link :)]
 
The only idea of the top of may head is that you may not need the final &quot;;&quot;<br><br>Could you post the error message please?<br><br>Jonathan <p> Jonathan<br><a href=mailto:j.w.george@virginnet.co.uk>j.w.george@virginnet.co.uk</a><br><a href= > </a><br>Working with: Visual Basic 6, Access 97, Visual Interdev 6, VBScript, Active Server Pages, SQL Server 6.5, Oracle 7, users who really have no idea what they want...
 
Sorry, that last post was supposed to go in a new Thread. The first one was supposed to be in this thread... I am losing it.<br><br>Anyway, your suggestion was perfect. And now Ieverything is working fine. As for the second post, I figured out what the problem was, I was using a reserved work (date AND time) in my table... Thanks alot on both counts. You saved me hours! <p>John Vogel<br><a href=mailto:johnvogel@homepage.com>johnvogel@homepage.com</a><br><a href= FreeDSL Service</a><br>[To a get FREE DSL Modem WITH FREE DSL Unlimited Internet Connection click the above link :)]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top