DLookup with LEFT and RIGHT (1 Viewer)

Malcolm17

Member
Local time
Today, 08:38
Joined
Jun 11, 2018
Messages
107
Hi,

Please can you help me find a way to display the left (or first) 13 characters of a field and also the right 13 characters in the same field as I need to display them separately in 2 different fields on a form. Below is what I have but cannot work out how to integrate left and right in to it.

'=DLookUp("Caption","PLUCaption","Code='1318'")'

Many thanks,

Malcolm
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:38
Joined
Sep 21, 2011
Messages
14,037
Assign that to a string and then use the Left & Right functions to that string?
3 strings in all.?
 

Malcolm17

Member
Local time
Today, 08:38
Joined
Jun 11, 2018
Messages
107
It would be 2 different strings really, so something like

For Field 1 =LEFT(13),DLookUp("Caption","PLUCaption","Code='1318'")
For Field 1 =RIGHT(13),DLookUp("Caption","PLUCaption","Code='1318'")

If it helps I have 1 field (always 26 characters) which says "Pint of Lager ", I want to show 1 field as "Pint of " and the other field as "Lager " - there is always have 13 characters for each field.
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 08:38
Joined
Sep 21, 2011
Messages
14,037
No.
That is two DLookUps, when you can get by with one.
Assign the DLookUp value to a string.
Then use Left() and Right() functions on that string to assign values to your controls.
Research those functions as well, as what you have there, is NOT how you use them.?
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:38
Joined
Sep 21, 2011
Messages
14,037
Your DlookUp should probably look more like
Code:
=DLookUp("Caption","PLUCaption","Code=1318")

Unless Code is Text, when it would have been correct.
 

onur_can

Active member
Local time
Today, 01:38
Joined
Oct 4, 2015
Messages
180
the following sub procedure will help you.
Code:
Public Sub PartCaption()
'-------------------------
' onur_can
' www.accessapplication.blogspot.com
'------------------------------------

Dim PartCaptionImport As String
Dim PartCaptionLeftImport As String
Dim PartCaptionRightImport As String

PartCaptionImport = DLookup("Caption", "PLUCaption", "Code =' 1318 '")
PartCaptionLeftImport = Left(PartCaptionImport, 13)
PartCaptionRightImport = Right(PartCaptionImport, 13)

' Field Use
'-------------------
' left side area
Forms!FormName!txtFields1 = PartCaptionLeftImport

' right side area
Forms!FormName!txtFields2 = PartCaptionRightImport

End Sub
 

Malcolm17

Member
Local time
Today, 08:38
Joined
Jun 11, 2018
Messages
107
Hi,

Thank you all for your suggestions, I have cracked it now
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:38
Joined
Sep 21, 2011
Messages
14,037
Hi,

Thank you all for your suggestions, I have cracked it now
Well for the benefit of others, who might need to do something similar, please post your solution within code tags.
 

onur_can

Active member
Local time
Today, 01:38
Joined
Oct 4, 2015
Messages
180
[QUOTE = "Malcolm17, gönderi: 1712889, üye: 146536"]
Hi,

Please can you help me find a way to display the left (or first) 13 characters of a field and also the right 13 characters in the same field as I need to display them separately in 2 different fields on a form. Below is what I have but cannot work out how to integrate left and right in to it.

'=DLookUp("Caption","PLUCaption","Code='1318'")'

Many thanks,

Malcolm
[/ALINTI]

Our friend did not say in one field, said in two different areas
 

Users who are viewing this thread

Top Bottom