PC Review


Reply
Thread Tools Rate Thread

Auto Fill Text Box

 
 
Brian
Guest
Posts: n/a
 
      16th Dec 2009
I am having trouble getting a text box to auto fill from a choice made from a
combo box.

Combo Box Name is Address_21
Text Box Name is City_1

My code is as follows:

'Auto Fill CES Spec Written Office

Private Sub ShowCity_1()
Dim Address_21 As Variant
Dim City_1 As Variant

If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
= Valrico
If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
Atlanta
If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
= Tampa
If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
UserForm1.City_1 = Atlanta
If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
Gastonia

End Sub

What did i do wrong or miss?
 
Reply With Quote
 
 
 
 
B Lynn B
Guest
Posts: n/a
 
      17th Dec 2009
Enclose each city name in double quotation marks. Otherwise VBA thinks
you're refering to a variable.

"Brian" wrote:

> I am having trouble getting a text box to auto fill from a choice made from a
> combo box.
>
> Combo Box Name is Address_21
> Text Box Name is City_1
>
> My code is as follows:
>
> 'Auto Fill CES Spec Written Office
>
> Private Sub ShowCity_1()
> Dim Address_21 As Variant
> Dim City_1 As Variant
>
> If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> = Valrico
> If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> Atlanta
> If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> = Tampa
> If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> UserForm1.City_1 = Atlanta
> If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> Gastonia
>
> End Sub
>
> What did i do wrong or miss?

 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      17th Dec 2009
I changed the city name to the following. When I go to the combo box and
choose my Address nothing happens. I missed something.

"Valrico"
"Atlanta"
"Tampa"
"Atlanta"
"Gastonia"


"B Lynn B" wrote:

> Enclose each city name in double quotation marks. Otherwise VBA thinks
> you're refering to a variable.
>
> "Brian" wrote:
>
> > I am having trouble getting a text box to auto fill from a choice made from a
> > combo box.
> >
> > Combo Box Name is Address_21
> > Text Box Name is City_1
> >
> > My code is as follows:
> >
> > 'Auto Fill CES Spec Written Office
> >
> > Private Sub ShowCity_1()
> > Dim Address_21 As Variant
> > Dim City_1 As Variant
> >
> > If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> > = Valrico
> > If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> > Atlanta
> > If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> > = Tampa
> > If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> > UserForm1.City_1 = Atlanta
> > If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> > Gastonia
> >
> > End Sub
> >
> > What did i do wrong or miss?

 
Reply With Quote
 
B Lynn B
Guest
Posts: n/a
 
      17th Dec 2009
Sorry, I should have looked more closely at everything that was going on. I
just quickly scanned and identified the most obvious thing that jumped out at
me.

Paste the following into your userform code.

Private Sub Address_21_Change()

Select Case Address_21
Case ""2306 Long Green Court"
City_1 = "Valrico"
Case ""3440 Oakcliff Road"
City_1 = "Atlanta"
Case "7015 East 14th Aveneue"
City_1 = "Tampa"
Case "1800 Taylor Drive"
City_1 = "Gastonia"
End Select

End Sub



"Brian" wrote:

> I changed the city name to the following. When I go to the combo box and
> choose my Address nothing happens. I missed something.
>
> "Valrico"
> "Atlanta"
> "Tampa"
> "Atlanta"
> "Gastonia"
>
>
> "B Lynn B" wrote:
>
> > Enclose each city name in double quotation marks. Otherwise VBA thinks
> > you're refering to a variable.
> >
> > "Brian" wrote:
> >
> > > I am having trouble getting a text box to auto fill from a choice made from a
> > > combo box.
> > >
> > > Combo Box Name is Address_21
> > > Text Box Name is City_1
> > >
> > > My code is as follows:
> > >
> > > 'Auto Fill CES Spec Written Office
> > >
> > > Private Sub ShowCity_1()
> > > Dim Address_21 As Variant
> > > Dim City_1 As Variant
> > >
> > > If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> > > = Valrico
> > > If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> > > Atlanta
> > > If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> > > = Tampa
> > > If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> > > UserForm1.City_1 = Atlanta
> > > If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> > > Gastonia
> > >
> > > End Sub
> > >
> > > What did i do wrong or miss?

 
Reply With Quote
 
B Lynn B
Guest
Posts: n/a
 
      17th Dec 2009
Oops, I see that I missed one of the combos. Or maybe got them mixed up.
But you get the drift and can correct as needed.

Another thought would be to employ the combo box Column property to load and
retrieve the associated city value that way. Go read the help entry on the
subject for further inspiration in that direction.

"B Lynn B" wrote:

> Sorry, I should have looked more closely at everything that was going on. I
> just quickly scanned and identified the most obvious thing that jumped out at
> me.
>
> Paste the following into your userform code.
>
> Private Sub Address_21_Change()
>
> Select Case Address_21
> Case ""2306 Long Green Court"
> City_1 = "Valrico"
> Case ""3440 Oakcliff Road"
> City_1 = "Atlanta"
> Case "7015 East 14th Aveneue"
> City_1 = "Tampa"
> Case "1800 Taylor Drive"
> City_1 = "Gastonia"
> End Select
>
> End Sub
>
>
>
> "Brian" wrote:
>
> > I changed the city name to the following. When I go to the combo box and
> > choose my Address nothing happens. I missed something.
> >
> > "Valrico"
> > "Atlanta"
> > "Tampa"
> > "Atlanta"
> > "Gastonia"
> >
> >
> > "B Lynn B" wrote:
> >
> > > Enclose each city name in double quotation marks. Otherwise VBA thinks
> > > you're refering to a variable.
> > >
> > > "Brian" wrote:
> > >
> > > > I am having trouble getting a text box to auto fill from a choice made from a
> > > > combo box.
> > > >
> > > > Combo Box Name is Address_21
> > > > Text Box Name is City_1
> > > >
> > > > My code is as follows:
> > > >
> > > > 'Auto Fill CES Spec Written Office
> > > >
> > > > Private Sub ShowCity_1()
> > > > Dim Address_21 As Variant
> > > > Dim City_1 As Variant
> > > >
> > > > If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> > > > = Valrico
> > > > If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> > > > Atlanta
> > > > If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> > > > = Tampa
> > > > If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> > > > UserForm1.City_1 = Atlanta
> > > > If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> > > > Gastonia
> > > >
> > > > End Sub
> > > >
> > > > What did i do wrong or miss?

 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      17th Dec 2009
I replaced my Code with this.

'Auto Fill CES Spec Written Office
Private Sub Address_21_Change()

Select Case Address_21
Case "2306 Long Green Court"
City_1 = "Valrico"
Case "3440 Oakcliff Road"
City_1 = "Atlanta"
Case "7015 East 14th Aveneue"
City_1 = "Tampa"
Case "1800 Taylor Drive"
City_1 = "Gastonia"
End Select

End Sub

I must be doing something wrong still, cause i can't get it work.
"B Lynn B" wrote:

> Sorry, I should have looked more closely at everything that was going on. I
> just quickly scanned and identified the most obvious thing that jumped out at
> me.
>
> Paste the following into your userform code.
>
> Private Sub Address_21_Change()
>
> Select Case Address_21
> Case ""2306 Long Green Court"
> City_1 = "Valrico"
> Case ""3440 Oakcliff Road"
> City_1 = "Atlanta"
> Case "7015 East 14th Aveneue"
> City_1 = "Tampa"
> Case "1800 Taylor Drive"
> City_1 = "Gastonia"
> End Select
>
> End Sub
>
>
>
> "Brian" wrote:
>
> > I changed the city name to the following. When I go to the combo box and
> > choose my Address nothing happens. I missed something.
> >
> > "Valrico"
> > "Atlanta"
> > "Tampa"
> > "Atlanta"
> > "Gastonia"
> >
> >
> > "B Lynn B" wrote:
> >
> > > Enclose each city name in double quotation marks. Otherwise VBA thinks
> > > you're refering to a variable.
> > >
> > > "Brian" wrote:
> > >
> > > > I am having trouble getting a text box to auto fill from a choice made from a
> > > > combo box.
> > > >
> > > > Combo Box Name is Address_21
> > > > Text Box Name is City_1
> > > >
> > > > My code is as follows:
> > > >
> > > > 'Auto Fill CES Spec Written Office
> > > >
> > > > Private Sub ShowCity_1()
> > > > Dim Address_21 As Variant
> > > > Dim City_1 As Variant
> > > >
> > > > If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> > > > = Valrico
> > > > If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> > > > Atlanta
> > > > If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> > > > = Tampa
> > > > If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> > > > UserForm1.City_1 = Atlanta
> > > > If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> > > > Gastonia
> > > >
> > > > End Sub
> > > >
> > > > What did i do wrong or miss?

 
Reply With Quote
 
B Lynn B
Guest
Posts: n/a
 
      17th Dec 2009
I just tested it and it works fine. Did you put it in the form's code
module? (i.e. when you have the form in design view, right-click it and
select View Code.)

"Brian" wrote:

> I replaced my Code with this.
>
> 'Auto Fill CES Spec Written Office
> Private Sub Address_21_Change()
>
> Select Case Address_21
> Case "2306 Long Green Court"
> City_1 = "Valrico"
> Case "3440 Oakcliff Road"
> City_1 = "Atlanta"
> Case "7015 East 14th Aveneue"
> City_1 = "Tampa"
> Case "1800 Taylor Drive"
> City_1 = "Gastonia"
> End Select
>
> End Sub
>
> I must be doing something wrong still, cause i can't get it work.
> "B Lynn B" wrote:
>
> > Sorry, I should have looked more closely at everything that was going on. I
> > just quickly scanned and identified the most obvious thing that jumped out at
> > me.
> >
> > Paste the following into your userform code.
> >
> > Private Sub Address_21_Change()
> >
> > Select Case Address_21
> > Case ""2306 Long Green Court"
> > City_1 = "Valrico"
> > Case ""3440 Oakcliff Road"
> > City_1 = "Atlanta"
> > Case "7015 East 14th Aveneue"
> > City_1 = "Tampa"
> > Case "1800 Taylor Drive"
> > City_1 = "Gastonia"
> > End Select
> >
> > End Sub
> >
> >
> >
> > "Brian" wrote:
> >
> > > I changed the city name to the following. When I go to the combo box and
> > > choose my Address nothing happens. I missed something.
> > >
> > > "Valrico"
> > > "Atlanta"
> > > "Tampa"
> > > "Atlanta"
> > > "Gastonia"
> > >
> > >
> > > "B Lynn B" wrote:
> > >
> > > > Enclose each city name in double quotation marks. Otherwise VBA thinks
> > > > you're refering to a variable.
> > > >
> > > > "Brian" wrote:
> > > >
> > > > > I am having trouble getting a text box to auto fill from a choice made from a
> > > > > combo box.
> > > > >
> > > > > Combo Box Name is Address_21
> > > > > Text Box Name is City_1
> > > > >
> > > > > My code is as follows:
> > > > >
> > > > > 'Auto Fill CES Spec Written Office
> > > > >
> > > > > Private Sub ShowCity_1()
> > > > > Dim Address_21 As Variant
> > > > > Dim City_1 As Variant
> > > > >
> > > > > If UserForm1.Address_21 = "2306 Long Green Court" Then UserForm1.City_1
> > > > > = Valrico
> > > > > If UserForm1.Address_21 = "3440 Oakcliff Road" Then UserForm1.City_1 =
> > > > > Atlanta
> > > > > If UserForm1.Address_21 = "7015 East 14th Aveneue" Then UserForm1.City_1
> > > > > = Tampa
> > > > > If UserForm1.Address_21 = "3890 Oakcliff Industrial Court" Then
> > > > > UserForm1.City_1 = Atlanta
> > > > > If UserForm1.Address_21 = "1800 Taylor Drive" Then UserForm1.City_1 =
> > > > > Gastonia
> > > > >
> > > > > End Sub
> > > > >
> > > > > What did i do wrong or miss?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto fill text =?Utf-8?B?Y2FjMTk2Ng==?= Microsoft Excel Worksheet Functions 1 2nd Apr 2007 08:29 PM
Auto-Fill text box to text box w/ EDIT capabilities =?Utf-8?B?RGlhbmFT?= Microsoft Access 3 4th Aug 2005 08:29 PM
How to auto-fill text based on text in another cell =?Utf-8?B?SmFzb24=?= Microsoft Excel Misc 3 16th Feb 2005 08:40 PM
HOW CAN I AUTO FILL A CELL WITH TEXT FROM ANOTHER WORKSHEET TEXT . =?Utf-8?B?d2F6?= Microsoft Excel Worksheet Functions 2 29th Dec 2004 07:49 PM
Auto Fill in a text box SheepDog Microsoft Access Forms 2 30th Jan 2004 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 PM.