Re: Global variable losing value for no apparent reason



Sorry but you're wrong there. It's the "+" concatenation operator that
evaluates to Null if one of the operands is null. The "&" operator treats
the Null operand as a zero-length string.

"JvC" <johnvonc@xxxxxxxxxxxxx> wrote in message
news:DEkjk.4653$LF2.2171@xxxxxxxxxxxxxxx
So the code used to work, and it doesn't now. If you look at the code you
posted below, I think your line:
MyStrVar = MyStrVar & "*" & !QryID & "*"
could be the problem. If you somehow got a dreaded NULL in !QryID, this
entire loop will evaluate to NULL. Is the tblDatabaseQueries table being
reloaded at some point, that would cause this behavior?

Look at your table, and find the record where !QryID is Null and fix it.
Then redesign the table so it doesn't allow Nulls in that field. Also, if
the table is being reloaded at some point, make sure all of the records
are cleared.

Good luck!

John

It happens that teddysnips@xxxxxxxxxxx formulated :
Set rcd = CurrentDb.OpenRecordset("SELECT tblDatabaseQueries.QryID
FROM tblDatabaseQueries;")
If rcd.RecordCount > 0 Then
With rcd
.MoveFirst
Do
MyStrVar = MyStrVar & "*" & !QryID & "*"
.MoveNext
Loop While Not (rcd.EOF)
End With
End If




.



Relevant Pages

  • Re: Global variable losing value for no apparent reason
    ... bcap brought next idea: ... evaluates to Null if one of the operands is null. ... If you somehow got a dreaded NULL in!QryID, this entire loop will evaluate to NULL. ...
    (comp.databases.ms-access)
  • Re: ^ operator in VB.Net what in C#?
    ... Regards - Octavio ... >> The Math.Powmethod accepts any double operands, so I guess it works by ... > Smaller pairs were much faster in a for loop, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How would I rewrite this to satisfy the code checker?
    ... saying, "Avoid assignments in operands". ... How would I rewrite the ... while loop to make this error go away but achieve the same ...
    (comp.lang.java.programmer)
  • Re: Another easy one I think
    ... > continue and process the 0 as an ordinary number and then stop the loop. ... > should terminate the loop immediately. ... > If you subtract one from count it will be 0 again and the division by zero ... convert one of the operands on the fly ...
    (comp.lang.java.help)
  • Re: #value! Error
    ... if either of its operands are text. ... You could use the concatenation operator, ... > The idea is to show in column D the names of upto 24 players, ...
    (microsoft.public.excel.misc)