Help with ControlSource - using a DLookup

  • Thread starter Thread starter acs68
  • Start date Start date
A

acs68

Hi there,

I have some code that I want to switch the ControlSouce property based on
what the user selects.

If btnOwners.Caption = "Show Current Owner" Then
btnOwners.Caption = "Show Owner When Created"
Me!txtPropOwner.ControlSource = "DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" & [Forms]![frmRequests]!txtLotPlan
& "'")"
Else
btnOwners.Caption = "Show Current Owner"
Me!txtPropOwner.ControlSource = "ReqOWNER"
End If

The dlookup part doesn't seem to work and I get errors.

Can someone please point me to the correct way of achieving this ?

cheers,

Adam
 
You must have an = character as the first character in the text string that
is to be the control source string:

Me!txtPropOwner.ControlSource = "=DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" & [Forms]![frmRequests]!txtLotPlan
& "'")"
 
Hi Ken,

tried:
Me!txtPropOwner.ControlSource =
"=DLookup("[PARCELADDR1]","tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan& "'")"

but it errors with inavild syntax. Something to do with the " I believe.

any ideas ?

cheers,

Adam


Ken Snell said:
You must have an = character as the first character in the text string
that is to be the control source string:

Me!txtPropOwner.ControlSource = "=DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan
& "'")"


--

Ken Snell
<MS ACCESS MVP>

acs68 said:
Hi there,

I have some code that I want to switch the ControlSouce property based on
what the user selects.

If btnOwners.Caption = "Show Current Owner" Then
btnOwners.Caption = "Show Owner When Created"
Me!txtPropOwner.ControlSource = "DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan & "'")"
Else
btnOwners.Caption = "Show Current Owner"
Me!txtPropOwner.ControlSource = "ReqOWNER"
End If

The dlookup part doesn't seem to work and I get errors.

Can someone please point me to the correct way of achieving this ?

cheers,

Adam
 
Sorry... I didn't count your " characters:

Me!txtPropOwner.ControlSource =
"=DLookup(""[PARCELADDR1]"",""tblPCSProperties"", ""[LotPlan] = '"" &
[Forms]![frmRequests]!txtLotPlan& ""'"")"

--

Ken Snell
<MS ACCESS MVP>

acs68 said:
Hi Ken,

tried:
Me!txtPropOwner.ControlSource =
"=DLookup("[PARCELADDR1]","tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan& "'")"

but it errors with inavild syntax. Something to do with the " I believe.

any ideas ?

cheers,

Adam


Ken Snell said:
You must have an = character as the first character in the text string
that is to be the control source string:

Me!txtPropOwner.ControlSource = "=DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan
& "'")"


--

Ken Snell
<MS ACCESS MVP>

acs68 said:
Hi there,

I have some code that I want to switch the ControlSouce property based
on what the user selects.

If btnOwners.Caption = "Show Current Owner" Then
btnOwners.Caption = "Show Owner When Created"
Me!txtPropOwner.ControlSource = "DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan & "'")"
Else
btnOwners.Caption = "Show Current Owner"
Me!txtPropOwner.ControlSource = "ReqOWNER"
End If

The dlookup part doesn't seem to work and I get errors.

Can someone please point me to the correct way of achieving this ?

cheers,

Adam
 
legendary stuff,

thanks Ken !!

cheers,

Adam


Ken Snell said:
Sorry... I didn't count your " characters:

Me!txtPropOwner.ControlSource =
"=DLookup(""[PARCELADDR1]"",""tblPCSProperties"", ""[LotPlan] = '"" &
[Forms]![frmRequests]!txtLotPlan& ""'"")"

--

Ken Snell
<MS ACCESS MVP>

acs68 said:
Hi Ken,

tried:
Me!txtPropOwner.ControlSource =
"=DLookup("[PARCELADDR1]","tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan& "'")"

but it errors with inavild syntax. Something to do with the " I believe.

any ideas ?

cheers,

Adam


Ken Snell said:
You must have an = character as the first character in the text string
that is to be the control source string:

Me!txtPropOwner.ControlSource = "=DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan
& "'")"


--

Ken Snell
<MS ACCESS MVP>

Hi there,

I have some code that I want to switch the ControlSouce property based
on what the user selects.

If btnOwners.Caption = "Show Current Owner" Then
btnOwners.Caption = "Show Owner When Created"
Me!txtPropOwner.ControlSource = "DLookup("[PARCELADDR1]",
"tblPCSProperties", "[LotPlan] = " & "'" &
[Forms]![frmRequests]!txtLotPlan & "'")"
Else
btnOwners.Caption = "Show Current Owner"
Me!txtPropOwner.ControlSource = "ReqOWNER"
End If

The dlookup part doesn't seem to work and I get errors.

Can someone please point me to the correct way of achieving this ?

cheers,

Adam
 
Back
Top