View Full Version : Seeing 'ID' instead 'Name'


Jonny
02-22-2008, 11:41 PM
Hello friends,

I wrote some code for sending email from when I pressing the button in a form.
But when the message is opening , instead 'Me.DeliveredBy', 'Me.ManufacturerName ' and 'Me.SupplierName' I see only their 'IDs", and not the name.

Any advise, what's wrong?

Private Sub btnSendReceipt_Click()
On Error GoTo Err_btnSendReceipt_Click

Dim stDocName As String

stDocName = "Samples"
DoCmd.SendObject acSendNoObject, stDocName, acFormatHTML, _
Me.DeliveredBy, , , _
"Your Samples Have Received", _
"SLF#: " & Me.txtSLF & vbCrLf & _
"Our Item: " & Me.Item & vbCrLf & _
"Supplier Name: " & Me.SupplierName & vbCrLf & _
"Manufacturer Name: " & Me.ManufacturerName & vbCrLf & _
"Manufacturer Part Number: " & Me.ManufacturerPN & vbCrLf & _
"Quantity Received: " & Me.Quantity & vbCrLf & _
"Received On: " & Me.Received_Date() _
, True

Exit_btnSendReceipt_Click:
Exit Sub

Err_btnSendReceipt_Click:
MsgBox Err.Description
Resume Exit_btnSendReceipt_Click
End Sub

I attached all printscreens.

boblarson
02-22-2008, 11:45 PM
I would tend to suspect that you have lookups defined at table level, which is not good. See here for more info:

http://www.mvps.org/access/lookupfields.htm

Jonny
02-23-2008, 07:44 AM
I tried to follow your advise and canceled all "look up fields".
When I'm pressing combo box of SupplierID, I want to see not ID , but Supplier Name.
I added in 'Row Source' property of my form following "SELECT tblSuppliers.SupplierName FROM tblSuppliers ORDER BY tblSuppliers.SupplierName"

..but getting error "The value you entered isn't valid for this field", the reason for that my table expects to get a number, but in Coombo I want to show the name (that is text).

What I'd doing wrong?

boblarson
02-23-2008, 07:49 AM
You have to use:


"SELECT tblSuppliers.SupplierID,tblSuppliers.SupplierName FROM tblSuppliers ORDER BY tblSuppliers.SupplierName"


And then in the number of columns property put 2
and in the column widths put: 0";2"

That way it will show the text but it will store the ID, which is what it is wanting.

Jonny
02-23-2008, 09:48 AM
Bob, you gave me a good push with this.
I understood a number of my mistakes.
Thank you a lot