Variable adding ""

S

Stephen Lynch

My variable "strMaster2Use" is failing. For example, the first record
returned is 08004612 and it adds the "" to the string and causes the
recordset to return zero records. When I change it manually to lets say
12121212, another record in the set it runs.

do I declare it as a different kind of variable instead of a string? Need
help thanks.

*** code snippet***

Dim strMaster2Use as String
strMaster2Use = rst![MasterID] (it fails when the record starts with a
zero)

strSQL = "SELECT tblSellSharesParticipant.SchwabAccNo,
tblSellSharesParticipant.SellDecision, tblSellSharesParticipant.Symbol,
tblSellSharesParticipant.Shares, tblSellSharesParticipant.SecurityType,
tblSellSharesParticipant.MktValue, tblSellSharesParticipant.SharePrice,
tblSellSharesParticipant.SecDesc1,
tblSellSharesParticipant.SharesSubject2STRP,
tblSellSharesParticipant.SharesNotSubjectValue,
tblSellSharesParticipant.SellDollarAmount, tblSellSharesParticipant.MasterID
From tblSellSharesParticipant WHERE
(((tblSellSharesParticipant.SellDecision) Not Like 'Do Nothing') AND
((tblSellSharesParticipant.MasterID)= ' & strMaster2Use & ' ));"

this is the line I am having trouble with:

AND ((tblSellSharesParticipant.MasterID)= ' & strMaster2Use & ' ));"
 
D

Douglas J. Steele

strMaster2Use must be outside of the quotes.

Assuming MasterId is a text field, you need

((tblSellSharesParticipant.MasterID)= '" & strMaster2Use & "' ));"

Exagerated for clarity, that's

((tblSellSharesParticipant.MasterID)= ' " & strMaster2Use & " ' ));"

If MasterId is a numeric field, leave out the single quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top