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

Expression builder probs

Status
Not open for further replies.

jms137

Programmer
Oct 6, 2002
18
0
0
GB
Hi all vba'ers.

Excuse my ignorance, i am new to VBA (2 days) from a java background, quite a difference!!

Here's my query: I made a form with the wizard which has a series of text areas on it, displaying all the information in table 'ContractorSpend':

ContractorId(primary key), Cost00, Cost01, Cost02

I didn't have to code anything the wizard set it up. On the same form i have a Label. I basically want to take the 'ContractorId' value, and using Table 'Contractors':

ContractorId(primary key), FirstName, LastName

obtain the name values and load them into the label.

Now i coded a nice SQL statement with some ADO objects to do this, and put it in the FormCurrent() event and it works fine.

I wondered if there is an easier way to do it??? Is it possible to just open my form in 'design mode', right click on the label, and build an expression to do this, which would save me writing vb code?

Now i face my problems:
1) i don't know if this is possible
2) I cannot find ANY help on how to write expressions other than the crummy one in the Access help
3) Every time i try one there is a 'syntax error', but instead of giving me any info, the expression builder just automatically closes and i have to start again from scratch.

Here is my sql statement:

stSql = "SELECT Contractors.FirstName, Contractors.LastName FROM Contractors WHERE (((Contractors.ContractorId)=" & idval & "));"

'idval' is the value of the ContractorId I am searching for. It is lifted out of one of the controls.

Can anyone tell me what this statement should be in the expresssion builder?? Let's say the name of my label is 'NameLabel'.

Also , could anyone give me any URL's for some help on the expression builder?

it would be most appreciated
thanks
john
[gorgeous]
 
No. The way you are doing it is pretty simple. I'm not aware of a simpler way. You just wrote one page of question for this and you have already used the best, read only, means.

The sql statement assigns the values of the data to the controls and you then assign that value to the .caption.


-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
thanks sking,

yeah, wow, i really did write a page. i only ever mean to write a few sentences......

john
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top