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

Populating Unbound Text Box with result from query

Status
Not open for further replies.

ShaneKDev

Programmer
Nov 27, 2001
4
0
0
GB
Apologies in advance if this has been asked lots of times before - I've trawled through many threads both here and elsewhere and still haven't been able to sort things out....

...the problem is simple [or so I mistakenly thought]. All I want to be able to do is to copy the results of a query [which will always return one result] into an unbound textbox - something I thought would be straightforward in Access - but not so.... or I'm missing something...

Here's the deal - I've put together a fairly simple database which contains details about various products - along with an accompanying photograph - a table [Products] is used to store various details about each product - including a 'relative' pathname pointing to the location of the image for that product. I also have an unbound textbox on the form where the user can enter the 'base directory' to which the relative directories are appended to find the true location of each image.

When I manually type the base directory into the unbound text box everything works fine, but, as you'd expect when I close the database and restart it, the text box is empty and the user needs to populate it again with the base directory.....

...Obviously this isn't a desirable situation I at first I thought Access 2002 might provide some sort of persistent variable mechanism or datastore whereby you could store single 'configuration'-type variables which retain their values between subsequent database shutdowns and startups.... apparently there is no such feature....

...so, my next approach was to create a two-column database table [one column for the name of the config variable, and one column for the value of the config variable] - for now the table contains only one entry pair - "ImageBaseDir", "C:\"

The problem I'm now having is that I can't get Access 2002 to read the data from the configuration table and place the results in an unbound text box....

...I'm sure I'm not the only one that wants to achieve this sort of thing, so I'd appreciate it if anyone could point me in the right direction!

Cheers!

Shane.
 
not totally sure what you are trying to accomplish. are you trying to save yourself from having to know where the images are stored? is the 'base directory' different for each product? or are all the images in one place? if they are in one place, why does the path change?

In your new table, will there always only be one base path listed? Will people be changing this information frequently?

anyhow, with all my questions, try this:
in the form's OnOpen event, put

me.txtConfig = dlookup("Path","TableName")

txtConfig = the name of the unbound text box on the form. this will look in your new table (change the name) and get what you call the 'config variable' (change the 'PATH' to whatever you call that field)

not sure if this will totally help you--still unsure about the reason/direction you're going in.

g
 
GingerR,

This is exactly what I was after - thanks! [it was simple after all!]

Just to answer your questions anyway...

Yes - only one base directory is configured - I appreciate its not something which the user would be changing on a regular basis, but I wanted to provide a means by which the user could view/change the Base Directory through the form [if all the images had been moved for some reason] rather than having to dig around in database tables to change things, or hard-coding the value to the text-box.

Thanks again....

Shane.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top