Assigning String (1 Viewer)

illy2k

Registered User.
Local time
Today, 05:15
Joined
Apr 21, 2003
Messages
51
I keep getting an automation error in this snipet of code:

rst2.Find "[AccountNum] = #" & Me.AccountNum & "# "​
str_Name = rst2.Fields("SubAccount")​
rst3.Find "[Name] = '" & str_Name & "'"​

The error varies depending on if I have quotes around the:
rst2.Fields("SubAccount")
Anyone know how to shove rst2.Fields("SubAccount") into a string?
 

AlanS

Registered User.
Local time
Today, 00:15
Joined
Mar 23, 2001
Messages
292
Try this:

rst2.Find "[AccountNum] = '#" & Me.AccountNum & "# '"

I'm assuming that the field rst2.AccountNum contains a string value consisting of a pound sign, followed by an account number, followed by another pound sign, followed by a space. You need to embed the apostrophes when constructing criteria strings like this, to ensure that the "string within the string" is evaluated correctly.
 

Mile-O

Back once again...
Local time
Today, 05:15
Joined
Dec 10, 2002
Messages
11,316
illy2k said:
rst2.Find "[AccountNum] = #" & Me.AccountNum & "# "​
str_Name = rst2.Fields("SubAccount")​
rst3.Find "[Name] = '" & str_Name & "'"​

In line one, is your account number field actually of the date data type? You also have an erroneous space tagged within the string literal. ;)

str_Name isn't a particularly good name for a variable. strName is better.

Name isn't a good name for a field either as it's a reserved word in Access. :)

Anyway, can you describe the error? i.e. give it's description and number as given On Error
 

Users who are viewing this thread

Top Bottom