Another thought: After an entry of State is entered into the form, if
the user enters a wrong zip code that does not exit for the state, he
will see a message box. I tried to use array in VBA. But with 2,235 zip
code items, it was hard to build array. Can you help?
The Zipcodes would all exist in one single table no matter where they were
from. The table would be linked to a States table in a "one to many"
relationship.
(key field)
tblState [fldStateAbrv], [fldStateFullName]
1
----------
|
---------
8
tblZipCode [fldCodeNumber], [fldStateAbrv]
(key field) (foreign key)
The ZipCode selection box on the form would list the ZipCode values from the
tblZipCodes where the Foreign Key [fldStateAbrv] = the "text" value of the
form's control containing the State Abrv.
I can't give you exact code,...I'm not that good at it. But here are some
ideas. My few code samples may have errors, but they should point you in the
proper general direction.
On the LostFocus Event of the "State" control, have it populate the ZipCode
Selection control. You create saved Access Parameter Queries to use for this
without having to write a bunch of SQL queries. For example if the control
holding the State value was a Text Box called "txtState", it could take the
value of "txtState.Text" and use it as the parameter for that Parameter
Query to produce the content for the Zipcode Selection control.
On the GotFocus Event of the ZipCode Selection control, have it popup a
MessageBox if the State control value is empty. It should tell the user they
must fill in the Sate first,...when they click Ok on the Messagebox the
Focus is passed to the State control.
lstZipCode.Focus = False
txtState.Focus = True
One more thing: any idea or code about compare a zip code entry against
the array?
No way I could answer that,..I don't even see any need for an array.
Arrays, potentially, eat up a lot of memory. You would already have a
RecordSet in Memory,...just use it rather than doubling the amount of used
RAM by adding an Array that may be duplicating data already held in the
record set.
I sometimes use Arrays, but I try to close the RecordSet once the Array is
"loaded up" with data from the RecordSet.