On Mon, 10 Dec 2007 09:24:00 -0800, Tom wrote:
Hello again Fred.
Still getting an "Expected End of Statement" on the "Where". This is a copy
of the code... It's all on one line.... Hope we're getting closer.
Private Sub cboPartNmbr_AfterUpdate()
Me.cboDescription.RowSource = "Select tblParts.[Descrip]from tblParts"
where tblParts.[PartNmbr] = '" & me.[cboParts] & "';";
End Sub
:
On Sat, 8 Dec 2007 10:49:01 -0800, Tom wrote:
Hi Fred
I copied the code exactly as you typed it and removed the spaces between the
single and double quotes at both locations.
If I keep the code on one line, I get a compile error at the Where statement
telling me it expected an end of statement.
If I break the line at the where, I get a compile error at the first single
quote "Expcted: expression".
What is it telling me??
Thanx
:
On Fri, 7 Dec 2007 16:02:00 -0800, Tom wrote:
Ok Changed my field name to Descrip.
This what I entered in cboPartNmbr "AfterUpdate event:
Private Sub cboPartNmbr_AfterUpdate()
Me.cboDescription.RowSource = "Select tblParts.[Descrip]from tblParts"
where tblParts.[PartNmbr] = "& me.[cboParts] &" ' ";
End Sub
It hangs on the where statement....
the part number field is a text field... What did I not do correctly??
:
On Fri, 7 Dec 2007 15:06:01 -0800, Tom wrote:
I have two combo boxes. one for a part number and one for description. I
would like to limit the choices for the description combo box based on the
value in the part number box.
The table this is based on has two fields. PartNmbr and Desc. I found some
sample code at
www.databasedev.co.uk/filter_combo_boxes.html but am having
issues modifying it to suit my purpose.
Thanx for your help
NOTE: Desc is a reserved Access/VBA/Jet word and should not be used as
a field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:
109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
One method is to leave the second combo box rowsource blank.
After you change the Desc field name to something else, code the first
Combo AfterUpdate event:
Me.[Combo2].Rowsource = "Select TableName.[Desc] from TableName Where
TableName.[PartNmbr] = " & Me.[ComboName];
The above assumes the [PartNmbr] field is a Number datatype.
If the [PartNmbr] is actually Text datatype, then use:
Where TableName.[PartNmbr] = '" & Me.[ComboName] & "'";
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
It's always best to copy and paste the actual code you used, not, as I
suspect, re-type it here in the message. I have no idea if all of the
errors were all in your code or just in the re-typing.
I can only see this message and you have...
1) A space missing ... tblParts.[Descrip]from ... in front of the
word "from".
It needs to be there. It should be ...tblParts.[Descrip] from ....
2) You added a double quote after the word tblParts.
"Select tblParts.[Descrip]from tblParts " ....
That last quote should NOT be there.
3) You are missing a single quote.
.... where tblParts.[PartNmbr] = "& ...
should be
where tblParts.[PartNmbr] = ' " & (remove the space between the single
and double quote)
So, to re-write your code:
Me.cboDescription.RowSource = "Select tblParts.[Descrip] from tblParts
where tblParts.[PartNmbr] = ' " & me.[cboParts] & " ' ";
(it should all be on one line)
Remove the spaces between the single and double quotes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
It's telling you that I should have re-checked my post before I sent
it. Sorry.
The semicolon goes inside the last quote ... " ' ;"
"Select .... etc....
where tblParts.[PartNmbr] = '" & me.[cboParts] & "';"
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
"Select tblParts.[Descrip]from tblParts"
|
You didn't leave a space between [Descrip] and from
"Select tblParts.[Descrip]from tblParts"
|
and you added a " after tblParts.
where tblParts.[PartNmbr] = '" & me.[cboParts] & "';";
|
You seem to have added an additional semicolon at the end.
where tblParts.[PartNmbr] = '" & me.[cboParts] & "';"
is all you need.
To re-state the above:
1) you need a space between the words [Descrip] and from
2) Remove the quote after tblParts
3) Remove the final ; (leave the one within the "';")