Error Cant Assign A Value To This Object???

CharlesWhiteman

Registered User.
Local time
Today, 11:26
Joined
Feb 26, 2007
Messages
421
I'm using the following piece of code in my Db:

Code:
If strIpType = "Static" Then
MsgBox "This is a static IP Address" & vbCrLf & "Used For Dynamic IP's Only"
Exit Sub
Else
    Dim strTblRadsMacAddress As String
    strTblRadsMacAddress = DLookup("MacAddress", "TblRads", "PrimaryDataID = Forms!FrmPrimaryData.PrimaryDataID")
    Dim strRadacctMaxID As String
    strRadacctMaxID = DMax("[RadAcctID]", "RadAcct", "[UserName] = " & Chr(34) & strTblRadsMacAddress & Chr(34))
    Me.txtCurrentIPAddress = DLookup("FramedIPAddress", "RadAcct", "RadAcctID = '" & [strRadacctMaxID] & "'")
End If
err_handler:
Call LogError(Err.Number, Err.Description, "Refresh MAC Address()")

I have narrowed the error to the following line:

Code:
Me.txtCurrentIPAddress = DLookup("FramedIPAddress", "RadAcct", "RadAcctID = '" & [strRadacctMaxID] & "'")

The text box in question is an unbound text box on my form. I have the same section of code on a OnClick event and in that instance I do not get the error.

Also, the error only occurs on a machine with just Access 2007 Runtime version.

The error does not occur on my developer machine with full access 2007 or in the runtime version on the same laptop.

:confused:
 
Last edited:
Get rid of the square brackets around the variable name and be sure to handle nulls:

txtCurrentIPAddress = Nz(DLookup("FramedIPAddress", "RadAcct", "RadAcctID = '" & strRadacctMaxID & "'"), "")
 
Hi Bob, thanks for the tip on that question which worked. I handt used Nz prior as there is no change that a record can be created in the table without its PK

What did the brackets do?
 

Users who are viewing this thread

Back
Top Bottom