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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign passed value to combo box

Status
Not open for further replies.

CaptainBob007

Programmer
Dec 20, 2003
42
US
Hi -

I'm working on a form to store pictures associated with given properties. The picture part of it works fine, I'm trying to figure out the association to a property now.

In my first form, I have all the details about the property, with primary key PropID. The address of the property is shown in a combo box, with a bound column for the PropID (which is a long integer). On this form I have a button which opens the "add photo" form.

The "Add Photo" form has a similar combo box where you can type in an address and it will relate the PropID of that address. Primary key on this form is PhotoID.

In both forms, the address combo box populates a "PropID" text field (invisible) on the form, which serves as the link to the table.

I'm passing the PropID value from the property form to the AddPhoto form using OpenArgs, and the value is making it through to the form fine as I'm using a MsgBox to check it, however now I am trying to set the PropID value of the "AddPhoto" form with this passed value, and it keeps on giving me an error that I cannot assign that value. I've tried assigning the PropID to the proper column of the combo box and the PropID text field. I have also tried passing the text address into the Address combo box, and it wont let me assign any of the values.

How can I pass the value (either the Long Integer or the text, I really dont care) from the one form to the other so the photo I'm importing can be related to the correct property? I've been looking around the forum at lots of posts related to passing variables, but havent come across anything quite like this yet. Any help would be appreciated.

~Bob
 
Hi

You can pass a value from one form to another as you open the second form, using .openargs (see help)

or you can 'address' a value on one (open) from from another using syntact like Forms!MyFormName!MyControlName

Does that help?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Ken -

I'm well aware of the use of .openargs and also the addressing syntax, and as you can see from my original post the values are going to the form just fine. My problem is that in a statement like the following:

Dim PassedPropID As Long
PassedPropID = Me.OpenArgs

Me.PropID = PassedPropID

the last line generates an error that a value cannot be assigned.

I have also tried using Me.PropID.Value to no avail.

Any help as to how to get it to accept these values in the form would be greatly appreciated.

~Bob
 
Have you tried something like this ?
Me!PropID.SetFocus
Me!PropID.Text = PassedPropID

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

You say "either the Long Integer or the text, ", is PropId by any chance an autonumber?, if yes you cannot assign a value to it

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top