Apr 20 2006, 10:01 AM
I have a form with a list box that shows a list of requests that are unassigned.
When you double click on the list box, I want a different form to open. All of the text boxes on the second form are unbound. I want to specifically set the value of each field, but Access won't let me use the word me!
For example, if I were trying to do this all within the same form, I can use the code below:
me.txt_request_id = !Request_ID
How do I do this from a different form?
The Visual Basic help says I should be able to use this code but it doesn't work:
Forms!NAME_OF_FORM.Controls!txt_request_ID.text = "Some Value"
I've tried every variation of this that I can think of and nothing works!! Please help! I am building this database for work and I'm already behind schedule. I've looked in every Access book I have and can't find anything that will work!
Apr 20 2006, 10:06 AM
welcome to UA forums.
Check this FAQ
for reference issues.
If you execute this from the form with the listbox on it then the code would be:
orms!YourOtherForm.YourOtherFormsControl = "Some Value"
Apr 20 2006, 10:28 AM
No luck freakazeud!!
From the listbox form I first opened the other form (Named Assignment_Form) with this line:
DoCmd.OpenForm "Assignment_Form", acNormal
Then I tried this:
Oget the error: "Method 'Item' of Object 'Forms' failed"
I also tried:
Apr 20 2006, 10:34 AM
Try to wrap you names in square brackets:
Make sure the form is open when you call this.
Apr 20 2006, 10:45 AM
Thanks freakazeud, but still no luck.
get the same error: "Method 'Item' of Object 'Forms' failed"
Apr 20 2006, 10:48 AM
Can you attach an example db so I can take a look at it?
Apr 20 2006, 11:04 AM
Could be mis reading the posters request but could it be that:
The form opening the form to be opened is closed?
The Expressions are not on the form to be opened?
Just A Thought
Apr 20 2006, 11:07 AM
It won't let me attach the database. I tried just changing the extension to .jpg. I don't know if you'll be able to convert it back to .mdb.
The Main form I am working with is "Unassigned_Request_Search". This form has the list box.
When you double click it, I am passing the value of the Request_ID to a Public Function called "Open_Assignment_Form(Req_ID As String)".
Then within the public function I am opening the second form called "Assignment_Form". That's where I get stuck. I added some notes to the code!
Thanks for taking a look at this!
Apr 20 2006, 11:10 AM
You have to zip up the mdb file and it has to be under 500kb (do a compact and repair if it is too big or take some stuff out).
HAs I mentioned before the form has to be opened when you call this AND you are doing this from the form which holds the listbox. With that info and the syntax I gave you it should work.
Apr 20 2006, 11:11 AM
Attachment needs to be Zipped and attached with a .zip extension no larger than 500000kb
Apr 20 2006, 11:12 AM
Ok, let's try to attach this again!
Apr 20 2006, 11:15 AM
There we go! I got it to attach.
John/jmcwk - Yes, both forms are open.
Freakazeud - I tried it both from the Public Function, and from the Unassigned_Request_Search form. I get the same error.
Apr 20 2006, 11:51 AM
something is wrong with your database. I imported your two forms and the module and tried it and it worked as supposed to. So try to import your objects into a new blank db. Maybe some dll broke and messes things up because the syntax is all correct. You don't need to do this in a seperate module by the way. Just do it on the double click event.
Apr 20 2006, 12:02 PM
Thanks, I'll try that! I am heading to the Dentist for the rest of this afternoon.
Do you think it could be a reference issue? Can you tell me what you have referenced?
I currently have:
Visual Basic for Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Apr 20 2006, 12:06 PM
There is a possibility that it is a reference issue.
The references seem fine, but they might be broken somehow. So try the import as I did and see if the syntax works then, because it didn't throw an error for me anymore afterwards.
Apr 21 2006, 08:03 AM
imported all of my objects into a new db, and it appears to be working fine now!
Odouble checked the references, and everything was the same. I'm not sure what caused this, but at least it is working now!
Thanks a ton for all of your help!
Apr 21 2006, 09:19 AM
Yeah like I said the references seemed fine, but maybe something just went haywire with them.
Glad you got it sorted out.
Good luck on future projects!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here