p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Microsoft Office > Access and Access VBA > Access VBA
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 28th, 2003, 11:24 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Denver, CO, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing values to a form

I have an unbound form with two text boxes. I want the form to open with values assigned to each box, let the user change those values and assign those new values to variables when the form is closed. I vaguely remember how to do this, but I am having trouble getting it to work. Specifically, I get an "Application-defined or object-defined error" when I try to show the form. Here is my code:

    datBeginDate = #3/1/2001#
    datEndDate = Date
    strFormName = "frm Get Dates"
    DoCmd.OpenForm strFormName, , , , , acHidden
    Forms(strFormName)!TxtBeginDate = datBeginDate
    Forms(strFormName)!txtEndDate = datEndDate
    datBeginDate = Forms(strFormName).TxtBeginDate
    datEndDate = Forms(strFormName).txtEndDate
    Forms(strFormName).show Modal

Would someone tell me what I am doing wrong? Thanks.

- Mark Schenk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 30th, 2003, 10:14 AM
Authorized User
Points: 256, Level: 5
Points: 256, Level: 5 Points: 256, Level: 5 Points: 256, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , FL, USA.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anywhere you have this Forms(strFormName) you need to change it to this Forms("strFormName"). That should do it for you. Also if you want the user to change the information why are you opening the form as acHidden?

Kenny Alligood
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 30th, 2003, 03:25 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Denver, CO, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response. strFormName is not the name of the form; the form's name is "frm Get Dates". strFormName is a string variable to which I assigned the form's name. It does not make sense to me to put a variable within quotes. In other words, writing
Forms("frm Get Dates")!txtBeginDate = datBeginDate
makes sense to me, but not
Forms("strFormName")!txtBeginDate = datBeginDate.

I hide the form initially so that I can assign values to the text boxes before the user sees the form. I then make the form visible later in the code.

- Mark


Quote:
quote:Originally posted by Kenny Alligood
 Anywhere you have this Forms(strFormName) you need to change it to this Forms("strFormName"). That should do it for you. Also if you want the user to change the information why are you opening the form as acHidden?

Kenny Alligood
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old November 30th, 2003, 05:35 PM
Authorized User
Points: 256, Level: 5
Points: 256, Level: 5 Points: 256, Level: 5 Points: 256, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , FL, USA.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for the initial reply. I have taken your code and put it into a working db (I also really looked at it this time) and found this possible solution. First off the last line of your code is actually generating the error //Forms(strFormName).show Modal// due to the fact that .Show is not an option in this context. What I suggest is changing that last line to look like this:

Forms(strFormName).Visible = True

It accomplishes the same thing but doesn't generate an error. As for the modal property why not just set that in the forms property sheet? If you would rather set it in code you can use this:

Forms(strFormName).Modal = True

Hope this helps you.

Kenny Alligood
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old November 30th, 2003, 11:39 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: Denver, CO, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Kenny. Actually, I solved the problem with this form by setting default values in the form itself. That way, I do not have to start the form hidden. Your suggestion will come in handy, however, for the next part of my application where I do have to pass values to the form before displaying it.
I noticed that Show was not one of the options presented for this form. I am confused about the difference between Show and Visible. Maybe someone can enlighten me.
What really goads me is that I wrote four applications in Access anywhere from four to ten years ago. Now, I cannot remember the first thing about it. Must be that "oldtimers" disease.

- Mark

Quote:
quote:Originally posted by Kenny Alligood
 Sorry for the initial reply. I have taken your code and put it into a working db (I also really looked at it this time) and found this possible solution. First off the last line of your code is actually generating the error //Forms(strFormName).show Modal// due to the fact that .Show is not an option in this context. What I suggest is changing that last line to look like this:

Forms(strFormName).Visible = True

It accomplishes the same thing but doesn't generate an error. As for the modal property why not just set that in the forms property sheet? If you would rather set it in code you can use this:

Forms(strFormName).Modal = True

Hope this helps you.

Kenny Alligood
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Form Values in ASP.Net sankar General .NET 10 September 21st, 2006 12:13 PM
passing values Ramakrishna ASP.NET 1.1 2 September 7th, 2004 08:13 AM
Passing form values from 1 frame to another. edkeyte Javascript How-To 4 February 2nd, 2004 12:33 PM
passing Multidimensional Array Values back to form stitch Classic ASP Databases 1 September 4th, 2003 04:33 PM
Passing Values from a Form to another Louisa Beginning VB 6 1 September 2nd, 2003 08:56 AM



All times are GMT -4. The time now is 11:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc