By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

Link text box to a table

P: n/a
Good morning, i have a table "tblQSPTotals" whith the fields "QspName"
and "Project Parts". The first obviously has all the QSP name in and
next to it the Project Parts which is total parts.
I need to bring those totals into a textbox on an overview sheet with
the various QSP's photo's on, could you please help on this one, i am at
a dead end !!

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Tempy wrote:
Good morning, i have a table "tblQSPTotals" whith the fields "QspName"
and "Project Parts". The first obviously has all the QSP name in and
next to it the Project Parts which is total parts.
I need to bring those totals into a textbox on an overview sheet with
the various QSP's photo's on, could you please help on this one, i am at
a dead end !!

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


A bit confusing. I'd recommend using Dlookup as the control source
=Dlookup("[Project Parts]","tblQSPTotals","QspName = '" & Me.QspName & "'")

I assume the current form has a Qspname on it. So, dlookup may help.

Or write a function
Function QSPTot(strQSP As STring) As Long
Dim rst As DAO.Recordset
set rst = Currentdb.Openrecordset("tblQSPTotals",dbopensanps hot)
rst.findfirst "QspName = '" & Me.QspName & "'"
If not rst.nomatch then QSPTot = rst![Project Parts]
rst.close
set rst = Nothing
End Function

This should run faster than dlookup. Again, enter something like
=QSPTot(Me.[Project Parts])
as the control source.
Nov 13 '05 #2

P: n/a
Hi Salad, Thanks once again for coming to my rescue, however as a newbie
to this game i am not sure where to put this, i have tried with no
success. Could i ask you to explain to me how this fits in to the jigsaw
puzzle.

thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
Tempy wrote:
Hi Salad, Thanks once again for coming to my rescue, however as a newbie
to this game i am not sure where to put this, i have tried with no
success. Could i ask you to explain to me how this fits in to the jigsaw
puzzle.

thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

As I stated before, the question posed was a bit confusing.

Open up the property sheet for the textbox. Under the Data tab, for
Control source, enter the dlookup of function that I provided. I will
assume the name is the same. The control source should look something like
=Dlookup("[Project Parts]","tblQSPTotals","QspName = '" & [QspName] & "'")

or if you use the function
=QSPTot([QSPName])

I would look at Dlookup in help and view the examples. I will assume
you have a field on the form called QspName.

The Dlookup gets the value of ProjectParts from the table tblQSPTotals
for the row where QspName equals the QspName of the current record.

ALso, don't cut out the response since that makes me have to go back and
forth between my reply and the new message.

Nov 13 '05 #4

P: n/a
Hi Salad, thanks, but i do not have a text box but Labels with the
peoples names on and the text boxes with totals underneath.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #5

P: n/a
Tempy wrote:
Hi Salad, thanks, but i do not have a text box but Labels with the
peoples names on and the text boxes with totals underneath.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


Could you describe your problem again? Try to write it in a way that a
person looking at the problem understands what you are trying to accomplish.
Nov 13 '05 #6

P: n/a
Hi Salad, sorry for the delay in the reply (From South Africa).
I have a form that has pictures of buyers on it and underneath each
picture a label with there names. Then underneath that i have a textbox
that i want to put in the total amount of parts that they are
responsible for. These totals are in a table called tblQSPTotals. This
table has two fields, "QSPName" and "ProjectParts", i can do this with a
whole lot of queries, but thought that there must be an easer way with
code but i am new at the game and do not know how to do this. Would it
make it easer to use a text box with thier names in, instead of the
label ?

Thanks for the help it is appreciated.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #7

P: n/a
Tempy wrote:
Hi Salad, sorry for the delay in the reply (From South Africa).
I have a form that has pictures of buyers on it and underneath each
picture a label with there names. Then underneath that i have a textbox
that i want to put in the total amount of parts that they are
responsible for. These totals are in a table called tblQSPTotals. This
table has two fields, "QSPName" and "ProjectParts", i can do this with a
whole lot of queries, but thought that there must be an easer way with
code but i am new at the game and do not know how to do this. Would it
make it easer to use a text box with thier names in, instead of the
label ?

Thanks for the help it is appreciated.

Tempy


I think so. No if you want to use a label, you use Caption. Let's say
you have a label called Label123 and you want to assign it the value in
a record Ex:
Dim rst As Recordset
set rst = Currentdb.openrecordset("Employees")
Me.Label123.Caption = rst.FirstName & " " & rst.LastName
rst.close
set rst = Nothing

If I am using a field, and want to simulate a label, I open the property
sheet for the field and click on the data tab and set the Locked
property to True and enabled property to False. In the Format tab I set
the SpecialEffect to Flat (not sunken) and switch BackStyle from Normal
to Transparent. If I want a box around it, I set the BorderStyle to Solid.

If you are going to use Labels, I recommend you give the labels a name
that means something to you as a developer. For example, I may drop a
text box onto the form and it may be named Text123 and the associated
label be called Label122. Each should have a name you can recognize. I
rarely care what a label is called unless I am changing its
caption...which appears to be what you are doing.

Let's say you are dropping several pics on a form. I guess you need to
scan through multiple records to do so. So you need to open the
recordset and loop through them and assign the variables to each field. Ex:
Dim rst As Recordset
Dim intFor As Integer
Dim strFieldName1 As String
Dim strFieldName2 As String
Dim strFieldName3 As String
set rst = Currentdb.OpenRecordset("tblQSPTotals")
For intFor = 1 to 4
strFieldName1 = "Pic" & intFor
strFieldName2 = "QSPName" & intFor
strFieldName3 = "ProjectParts" & intFor
Me(strFieldName1) = rst!Pic
Me(strFieldName2) = rst!QSPName
Me(strFieldName3) = rst!ProjectParts
rst.MoveNext
Next
rst.close
set rst = Nothing

In the above, I assign the 1st 4 pics to Pic1...Pic4,
QSPName1...QSPName4, ProjectParts1...ProjectParts4.

Hopefully something above will contain some concepts you can use.

Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.