Left align then space

  • Thread starter Thread starter dbl
  • Start date Start date
D

dbl

Hi I have data in an address field called CFAddress which has had the data
entered by a lookup process, when I tab back into the field CFAddress all
the data is highlighted. Is it possible to set the cursor to the left of
the field and the data moved over one space so that I can enter the property
name or number when I tab into the field. As below.

21 Longfellow Road

Thanks Bob
 
Hi,


Me.Text0.SetFocus
Me.Text0.SelStart=0

should do.


Hoping it may help,
Vanderghast, Access MVP
 
You can use the SelStart and SelLength properties of the control to do this.
Look in VBA Help for details.
 
Hi by using the following

Me.PrivateAddress.SetFocus
Me.PrivateAddress.SelStart=0

Deletes the data in the field and gives a result of "0" or "-1"

How do I keep the data in the field and have the cursor ready to type in the
house name or number, giving one space between the words?

The following code puts the data into the field private address

Dim ExistingPCode As Variant
Dim ExistingSN As Variant
Dim ExistingSL As Variant
Dim ExistingTO As Variant
Dim ExistingCO As Variant

ExistingPCode = DLookup("[txtPCPostCode]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingSN = DLookup("[txtPCStreetName]", "tblPostCode", "[txtPCPostCode]='"
& Me.PostalCode & "'")
ExistingSL = DLookup("[txtPCStreetLocation]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingTO = DLookup("[txtPCTown]", "tblPostCode", "[txtPCPostCode]='" &
Me.PostalCode & "'")
ExistingCO = DLookup("[txtPCCounty]", "tblPostCode", "[txtPCPostCode]='" &
Me.PostalCode & "'")


If Not IsNull(ExistingPCode) Then
Me.Private_Address = ExistingSN
Me.Address = ExistingSL
Me.City = ExistingTO
Me.County = ExistingCO
End If

Me.Private_Address.SetFocus
Me.Private_Address.SelStart = 0

Thanks Bob
 
Hi,


that sounds dependant of some setting (such as selecting all the existing
data when a text control get the focus). You may try to add a SelLength=0:


With Me.PrivateAddress
.Value = " " & Trim(.Value) ' prefix it with a space
.SetFocus
.SelLength=0
.SelStart = 0
End With


Note that if the user enters nothing, you end up with a starting space!



Hoping it may help,
Vanderghast, Access MVP

Bob said:
Hi by using the following

Me.PrivateAddress.SetFocus
Me.PrivateAddress.SelStart=0

Deletes the data in the field and gives a result of "0" or "-1"

How do I keep the data in the field and have the cursor ready to type in
the house name or number, giving one space between the words?

The following code puts the data into the field private address

Dim ExistingPCode As Variant
Dim ExistingSN As Variant
Dim ExistingSL As Variant
Dim ExistingTO As Variant
Dim ExistingCO As Variant

ExistingPCode = DLookup("[txtPCPostCode]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingSN = DLookup("[txtPCStreetName]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingSL = DLookup("[txtPCStreetLocation]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingTO = DLookup("[txtPCTown]", "tblPostCode", "[txtPCPostCode]='" &
Me.PostalCode & "'")
ExistingCO = DLookup("[txtPCCounty]", "tblPostCode", "[txtPCPostCode]='" &
Me.PostalCode & "'")


If Not IsNull(ExistingPCode) Then
Me.Private_Address = ExistingSN
Me.Address = ExistingSL
Me.City = ExistingTO
Me.County = ExistingCO
End If

Me.Private_Address.SetFocus
Me.Private_Address.SelStart = 0

Thanks Bob


Michel Walsh said:
Hi,


Me.Text0.SetFocus
Me.Text0.SelStart=0

should do.


Hoping it may help,
Vanderghast, Access MVP
 
Michel that works fine thanks very much for your help.

Bob
Michel Walsh said:
Hi,


that sounds dependant of some setting (such as selecting all the existing
data when a text control get the focus). You may try to add a SelLength=0:


With Me.PrivateAddress
.Value = " " & Trim(.Value) ' prefix it with a space
.SetFocus
.SelLength=0
.SelStart = 0
End With


Note that if the user enters nothing, you end up with a starting space!



Hoping it may help,
Vanderghast, Access MVP

Bob said:
Hi by using the following

Me.PrivateAddress.SetFocus
Me.PrivateAddress.SelStart=0

Deletes the data in the field and gives a result of "0" or "-1"

How do I keep the data in the field and have the cursor ready to type in
the house name or number, giving one space between the words?

The following code puts the data into the field private address

Dim ExistingPCode As Variant
Dim ExistingSN As Variant
Dim ExistingSL As Variant
Dim ExistingTO As Variant
Dim ExistingCO As Variant

ExistingPCode = DLookup("[txtPCPostCode]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingSN = DLookup("[txtPCStreetName]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingSL = DLookup("[txtPCStreetLocation]", "tblPostCode",
"[txtPCPostCode]='" & Me.PostalCode & "'")
ExistingTO = DLookup("[txtPCTown]", "tblPostCode", "[txtPCPostCode]='" &
Me.PostalCode & "'")
ExistingCO = DLookup("[txtPCCounty]", "tblPostCode", "[txtPCPostCode]='"
& Me.PostalCode & "'")


If Not IsNull(ExistingPCode) Then
Me.Private_Address = ExistingSN
Me.Address = ExistingSL
Me.City = ExistingTO
Me.County = ExistingCO
End If

Me.Private_Address.SetFocus
Me.Private_Address.SelStart = 0

Thanks Bob


Michel Walsh said:
Hi,


Me.Text0.SetFocus
Me.Text0.SelStart=0

should do.


Hoping it may help,
Vanderghast, Access MVP


Hi I have data in an address field called CFAddress which has had the
data entered by a lookup process, when I tab back into the field
CFAddress all the data is highlighted. Is it possible to set the
cursor to the left of the field and the data moved over one space so
that I can enter the property name or number when I tab into the field.
As below.

21 Longfellow Road

Thanks Bob
 
Back
Top