Clarification:
My interpretation of the following statement:
"I also have a field called ZONES and would like the zone
in a separate table to be entered when the suburb is
selected, as well as the Postcode."
is that the ZONES field is a foreign key field in the form's current recordset. The OP wants to
populate this field using the primary key value stored in a parent (lookup) table, possibly in a
field of the same name.
Tom
________________________________
Steve,
I think he said that Zone field was in a seperate table
I understood this--it is in a separate table. I believe your answer is incorrect. Note that the
original poster wants to pull a value from the zone table, and populate a zone field in the
form's current recordset. Your solution proposes to push the POSTCODE value into the zone table.
That's not the task the OP asked to accomplish.
0 for 2 now.
Tom
____________________________________
I think he said that Zone field was in a seperate table -- meaning it's not
the table bounded to the form, is that correct Roger??
IF so then you would need to open up that other table and write it in
SOMETHING like this:
Private Sub SUBURB_AfterUpdate()
Dim rs as Recordset
Set rs = CurrentDb.OpenRecordset("othertablenamehere")
Me.POSTCODE = Me.SUBURB.Column(1)
rs.AddNew
rs!Zone = Me.SUBURB.Column(x)
rs.Update
rs.close
End Sub
--
_______________________
Steve Huff
http://www.huffs.us
Generic email: (e-mail address removed)
____________________________________
Hi Roger,
This should be possible. Click on the ellipses button (the button with the three dots) for the
combo box property that reads Row Source. This should open up the query builder. Add the table
that includes the zone primary key and perhaps a zone description. Make sure that a relationship
exists between the tables, otherwise, you will end up with a Cartesian product result. On the
format tab for the combo box, increase the column count property, and set the column widths
appropriately. If the zone primary key is an autonumber, then you'll likely want to refer to this
column, but leave its width = 0 so that it won't be visible to the user.
Then you'd simply refer to it by column position, keeping in mind that the columns are zero
based:
Private Sub SUBURB_AfterUpdate()
Me.POSTCODE = Me.SUBURB.Column(1)
Me.Zone = Me.SUBURB.Column(x)
End Sub
where x is the appropriate number, likely 2 or 3 depending on which order you added the zone
primary key and zone description field(s).
Tom
____________________________________
I have created an event procedure that looks up the
postcode when the Suburb is selected as follows:
Private Sub SUBURB_AfterUpdate()
Me.POSTCODE = Me.SUBURB.Column(1)
End Sub
I also have a field called ZONES and would like the zone
in a seperate table to be entered when the suburb is
selected, as well as the Postcode.
Can this procedure be added to the existing After update
procedure or if not, how do I get this to work
Thanks for any help