Sql insert statment from from list box to table or form

  • Thread starter Thread starter jeremy0028
  • Start date Start date
J

jeremy0028

I have the following list box called list0 with the following in row
source.

SELECT tblCityStateZip.City, tblCityStateZip.State,
tblCityStateZip.Zip
FROM tblCityStateZip;

i have a form called frmpeople with the following

PeopleID
LastName
FirstName
Address
City
State

Zip(Combo Box)
SELECT tblCityStateZip.Zip, tblCityStateZip.City,
tblCityStateZip.State
FROM tblCityStateZip;


What i want to do is when user double clicks on city state zip in the
list box will insert those in the form called people where it says
City,State,Zip.


Any ideas.
 
Jeremy,

Well, is the list0 listbox also on the frmpeople form? Or, if it's on
another form, is the frmpeople form open at the time?

Any reason for wanting to use double click, as against just selecting an
item from the listbox?

Anyway, code could be something like this...

With Forms!frmpeople
!City = Me.List0
!State = Me.List0.Column(1)
!Zip = Me.List0.Column(2)
End With

.... or, if list0 is on the same form:

Me.City = Me.List0
Me.State = Me.List0.Column(1)
Me.Zip = Me.List0.Column(2)
 
Jeremy,

Well, is the list0 listbox also on the frmpeople form? Or, if it's on
another form, is the frmpeople form open at the time?

Any reason for wanting to use double click, as against just selecting an
item from the listbox?

Anyway, code could be something like this...

With Forms!frmpeople
!City = Me.List0
!State = Me.List0.Column(1)
!Zip = Me.List0.Column(2)
End With

... or, if list0 is on the same form:

Me.City = Me.List0
Me.State = Me.List0.Column(1)
Me.Zip = Me.List0.Column(2)

--
Steve Schapel, Microsoft Access MVP









- Show quoted text -

Yes the list box is on another form called frmDuplicateZipcode. Since
some cities can have the same zipcode associated with them the form
pops up when user enters zipcode in the combobox on the frmpeople to
make user aware there are 2 or more cities associated with that zip
code. Then user double clicks the the correct city and will insert
that into the frmpeople where it says City,State, Zip.
 
Back
Top