Parameter setting itself to empty before call (1 Viewer)

BeeJayEff

Registered User.
Local time
Yesterday, 16:56
Joined
Sep 10, 2013
Messages
198
I have the following code :
Code:
Dim strBaseFileName As String
.
.
MsgBox "Moving files for " & strBaseFileName & ", " & SaleEventID
Call MoveImageFiles(FromStatus, 0, strBaseFileName, ToStatus, SaleEventID)
And
Code:
Public Sub MoveImageFiles(strOldStatus As String, _
                          lngOldID As Long, _
                          strFileName As String, _
                          strNewStatus As String, _
                          lngNewID As Long)
The MoveImageFiles routine works fine in other uses, but in this one particular call, the MsgBox gives the strBaseFileName value expected but if I step onto the next (Call) statement and hover over the field name it just gives me "strBaseFileName=" (with no value, not even ""). The other parameters all have their correct values. This is before executing the call.

In desperation, I have tried changing the parameter to ByVal, and Compacting/Repairing the database. All to no effect.

What's going on ?
 

Ranman256

Well-known member
Local time
Yesterday, 19:56
Joined
Apr 9, 2015
Messages
4,337
It is null. Either convert it to "" or
set the argument to variant (allows nulls) instead of string.
 

BeeJayEff

Registered User.
Local time
Yesterday, 16:56
Joined
Sep 10, 2013
Messages
198
But it's not null in the MsgBox immediately beforehand. What is causing it to change ?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:56
Joined
Feb 19, 2013
Messages
16,668
have you freetyped your first bit of code? Is it possible you have typed what it should be, rather than what it is?

Do you have Option Explicit at the top of the module?
 

BeeJayEff

Registered User.
Local time
Yesterday, 16:56
Joined
Sep 10, 2013
Messages
198
No, I copied and pasted all three lines of code. Here they are again (just to check) with a bit more context for the call to the routine ...

Code:
Dim strBaseFileName As String
.
.
Do Until adRs.EOF
    strBaseFileName = adRs!BaseFileName
    MsgBox "Moving files for " & strBaseFileName & ", " & SaleEventID
    Call MoveImageFiles(FromStatus, 0, strBaseFileName, ToStatus, SaleEventID)
     adRs.MoveNext
Loop
.
.
Originally the adRS!BaseFileName was used as the parameter, but I removed that when I first hit the problem.

Yes, Option Explicit is at the top of both modules (MoveImageFiles is in a Utility module).
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:56
Joined
Sep 12, 2006
Messages
15,710
can you see how the value gets passed into the called procedure? Is it failing because of the null, or failing because of a zls?

can you post your actual code from the declaration header down to the call statement?
are you sure it isn't looping through the recordset, and finding a blank on one iteration.
 

BeeJayEff

Registered User.
Local time
Yesterday, 16:56
Joined
Sep 10, 2013
Messages
198
Further investigation reveals that it is in fact passing the filename into the routine. My problem is something to do with my use of the code window ...

If I run into this code with adRS!BaseFileName = "USAJ04364" and SaleEventId = 1043, for example, and then pause the code at the MsgBox line and hover the mouse pointer over the SaleEventId field, it shows me the expected value (1043). However, if I hover over either the adRS!BaseFileName or the strBaseFileName field, it shows a null value - BUT, if I use the immediate window and enter ?strBaseFileName, it gives me the expected value ("USAJ04364"). So the correct value is indeed being passed in, and the question becomes why doesn't hovering over the field produce the expected result (which is not such a crucial issue, but a pain when debugging) ?
 

Users who are viewing this thread

Top Bottom