My function won't function. Please assist?

  • Thread starter Thread starter Sue
  • Start date Start date
S

Sue

I want the BusinssCity field & BusinessZip field to be automatically filled
in with Durham and 27710 respectively if the BusinessName = Duke. What's
wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and "27710"
for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and "27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being called.
Either put a breakpoint in it (click in the margin to the left of the code)
or put a message box just to be sure. If it's not being called, look at the
properties for the BusinessName text box and make sure that the AfterUpdate
event says [Event Procedure].
 
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update" reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



Douglas J. Steele said:
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the left of
the code) or put a message box just to be sure. If it's not being called,
look at the properties for the BusinessName text box and make sure that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Sue said:
I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName = Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
The Before Update event is not affecting your problem. It does nothing.

Doug's code should work for you. There is something going on you don't know
about. It would be helpful if you would specify exactly what kind of objects
each of the items you reference are. Post back with the following info:
Control Type, Bound control (Y/N), Field Name it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update" reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



Douglas J. Steele said:
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the left of
the code) or put a message box just to be sure. If it's not being called,
look at the properties for the BusinessName text box and make sure that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Sue said:
I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName = Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY tblCity.CityName;
BusinessZip - is a bound control, a combo box, set to SELECT
[tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM [tblZip/PostalCode] ORDER BY
[tblZip/PostalCode].[Zip/PostalCodeName];

Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there? Should I
delete it?

Klatuu said:
The Before Update event is not affecting your problem. It does nothing.

Doug's code should work for you. There is something going on you don't
know
about. It would be helpful if you would specify exactly what kind of
objects
each of the items you reference are. Post back with the following info:
Control Type, Bound control (Y/N), Field Name it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update"
reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



Douglas J. Steele said:
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the left
of
the code) or put a message box just to be sure. If it's not being
called,
look at the properties for the BusinessName text box and make sure that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName =
Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
Sue,

I might not be able to give an answer to the main question, here is the
answer to why the BeforeUpdate event exists. It exists to allow you to
validate data before it is saved. Below is the excerpt from the Microsoft
Access Help file:

The following example shows how you can use a BeforeUpdate event procedure
to check whether a product name has already been entered in the database.
After the user types a product name in the ProductName box, the value is
compared to the ProductName field in the Products table. If there is a
matching value in the Products table, a message is displayed that informs the
user that the product has already been entered.

To try the example, add the following event procedure to a form named
Products that contains a text box called ProductName.

Visual Basic for Applications
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
If(Not IsNull(DLookup("[ProductName]", _
"Products", "[ProductName] ='" _
& Me!ProductName & "'"))) Then
MsgBox "Product has already been entered in the database."
Cancel = True
Me!ProductName.Undo
End If
End Sub

Hopefully this helps in the future.

Wade

Sue said:
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY tblCity.CityName;
BusinessZip - is a bound control, a combo box, set to SELECT
[tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM [tblZip/PostalCode] ORDER BY
[tblZip/PostalCode].[Zip/PostalCodeName];

Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there? Should I
delete it?

Klatuu said:
The Before Update event is not affecting your problem. It does nothing.

Doug's code should work for you. There is something going on you don't
know
about. It would be helpful if you would specify exactly what kind of
objects
each of the items you reference are. Post back with the following info:
Control Type, Bound control (Y/N), Field Name it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update"
reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the left
of
the code) or put a message box just to be sure. If it's not being
called,
look at the properties for the BusinessName text box and make sure that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName =
Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
You're right, my initial question still goes unsolved, but thanks for the
info...
Now another question is raised in addition to the first - after reading your
post, it seems that my code is incomplete. All it says is:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub





Wade said:
Sue,

I might not be able to give an answer to the main question, here is the
answer to why the BeforeUpdate event exists. It exists to allow you to
validate data before it is saved. Below is the excerpt from the Microsoft
Access Help file:

The following example shows how you can use a BeforeUpdate event procedure
to check whether a product name has already been entered in the database.
After the user types a product name in the ProductName box, the value is
compared to the ProductName field in the Products table. If there is a
matching value in the Products table, a message is displayed that informs
the
user that the product has already been entered.

To try the example, add the following event procedure to a form named
Products that contains a text box called ProductName.

Visual Basic for Applications
Private Sub ProductName_BeforeUpdate(Cancel As Integer)
If(Not IsNull(DLookup("[ProductName]", _
"Products", "[ProductName] ='" _
& Me!ProductName & "'"))) Then
MsgBox "Product has already been entered in the database."
Cancel = True
Me!ProductName.Undo
End If
End Sub

Hopefully this helps in the future.

Wade

Sue said:
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY tblCity.CityName;
BusinessZip - is a bound control, a combo box, set to SELECT
[tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM [tblZip/PostalCode] ORDER
BY
[tblZip/PostalCode].[Zip/PostalCodeName];

Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there? Should I
delete it?

Klatuu said:
The Before Update event is not affecting your problem. It does
nothing.

Doug's code should work for you. There is something going on you don't
know
about. It would be helpful if you would specify exactly what kind of
objects
each of the items you reference are. Post back with the following
info:
Control Type, Bound control (Y/N), Field Name it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


:

Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update"
reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



message
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the
left
of
the code) or put a message box just to be sure. If it's not being
called,
look at the properties for the BusinessName text box and make sure
that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName =
Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity
and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
Sue,
The Before Update event normally does not exist in the form's module. At
some point, you clicked on something that caused it to create the procedure
in the code. It does nothing and you can delete it.

Very good info to work with on your question, thanks.

Based on your info, it may be that the information does not exist in the
city table or the zip code table. Also, as an example, your BusinessCity
control is a multi column combo. Since I don't know which is the bound
column, I can't say for sure, but unless you changed the default, it is
column 1 which is the CityID field. Therefore, populating it with the city
name will not work correctly. You would have to use the CityID value
instead; however, you may not have that available.

You will need to deal with both issues:
1. Is the City and Zipcode for Duke in the city table?
2. How do I relate the CityID to the CityName in the combo?

The same will be true for the BusinessZip field.
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY tblCity.CityName;
BusinessZip - is a bound control, a combo box, set to SELECT
[tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM [tblZip/PostalCode] ORDER BY
[tblZip/PostalCode].[Zip/PostalCodeName];

Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there? Should I
delete it?

Klatuu said:
The Before Update event is not affecting your problem. It does nothing.

Doug's code should work for you. There is something going on you don't
know
about. It would be helpful if you would specify exactly what kind of
objects
each of the items you reference are. Post back with the following info:
Control Type, Bound control (Y/N), Field Name it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the "BeforeUpdate"
property also says [Event Procedure], and the code for "Before Update"
reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's actually being
called. Either put a breakpoint in it (click in the margin to the left
of
the code) or put a message box just to be sure. If it's not being
called,
look at the properties for the BusinessName text box and make sure that
the AfterUpdate event says [Event Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be automatically
filled in with Durham and 27710 respectively if the BusinessName =
Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for BusinessCity and
"27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY
tblCity.CityName;

Your businesscity expects the City_ID. your code is trying to
put the name of the city there.


BusinessZip - is a bound control, a combo
box, set to SELECT [tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM
[tblZip/PostalCode] ORDER BY
[tblZip/PostalCode].[Zip/PostalCodeName];
Your businessZip expects the Zip/PostalCode_ID. your code is
trying to put the [Zip/PostalCodeName] there.





Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there?
Should I delete it?

Klatuu said:
The Before Update event is not affecting your problem. It
does nothing.

Doug's code should work for you. There is something going on
you don't know
about. It would be helpful if you would specify exactly what
kind of objects
each of the items you reference are. Post back with the
following info: Control Type, Bound control (Y/N), Field Name
it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


Sue said:
Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the
"BeforeUpdate" property also says [Event Procedure], and the
code for "Before Update" reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com>
wrote in message
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for
BusinessCity and "27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's
actually being called. Either put a breakpoint in it
(click in the margin to the left of
the code) or put a message box just to be sure. If it's
not being called,
look at the properties for the BusinessName text box and
make sure that the AfterUpdate event says [Event
Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be
automatically filled in with Durham and 27710 respectively
if the BusinessName = Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for
BusinessCity and "27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
I understand what you're saying but I don't know how to fix it.
Can you help with that?

Thanks.


Bob Quintal said:
Hi Dave,
Again, thanks to all for your assistance.
Here's the info you requested:

BusinessName - is a bound control, a combo box, set to SELECT
tblBusinessName.Business_ID, tblBusinessName.BusinessName FROM
tblBusinessName ORDER BY tblBusinessName.BusinessName;
BusinessCity - is a bound control, a combo box, set to SELECT
tblCity.City_ID, tblCity.CityName FROM tblCity ORDER BY
tblCity.CityName;

Your businesscity expects the City_ID. your code is trying to
put the name of the city there.


BusinessZip - is a bound control, a combo
box, set to SELECT [tblZip/PostalCode].[Zip/PostalCode_ID],
[tblZip/PostalCode].[Zip/PostalCodeName] FROM
[tblZip/PostalCode] ORDER BY
[tblZip/PostalCode].[Zip/PostalCodeName];
Your businessZip expects the Zip/PostalCode_ID. your code is
trying to put the [Zip/PostalCodeName] there.





Once again, I appreciate your assistance.
BTW - if the BeforeUpdate event does nothing, why is it there?
Should I delete it?

Klatuu said:
The Before Update event is not affecting your problem. It
does nothing.

Doug's code should work for you. There is something going on
you don't know
about. It would be helpful if you would specify exactly what
kind of objects
each of the items you reference are. Post back with the
following info: Control Type, Bound control (Y/N), Field Name
it is bound to, Data Type

For:
BusinessName
BusinessCity
BusinessZip
--
Dave Hargis, Microsoft Access MVP


:

Hi Doug - thank you for your willingness to help.
I tried your code, still without success.
The "AfterUpdate" box says [Event Procedure], but the
"BeforeUpdate" property also says [Event Procedure], and the
code for "Before Update" reads
as follows:

Private Sub BusinessName_BeforeUpdate(Cancel As Integer)

End Sub

Not sure how that happened. could that be the problem?



"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com>
wrote in message
Try:

Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for
BusinessCity and "27710"
for BusinessZip

Select Case Me!BusinessName
Case "Duke"
Me!BusinessCity = "Durham"
Me!BusinessZip = "27710"
End Select

End Sub

If that still doesn't work, make sure that the code's
actually being called. Either put a breakpoint in it
(click in the margin to the left of
the code) or put a message box just to be sure. If it's
not being called,
look at the properties for the BusinessName text box and
make sure that the AfterUpdate event says [Event
Procedure].

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want the BusinssCity field & BusinessZip field to be
automatically filled in with Durham and 27710 respectively
if the BusinessName = Duke.
What's wrong with this code?


Private Sub BusinessName_AfterUpdate()

' If BusinessName = Duke, then fill in "Durham" for
BusinessCity and "27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = "Durham"
BusinessZip = "27710"
End Select

End Sub


Thanks!
 
I understand what you're saying but I don't know how to fix it.
Can you help with that?

Thanks.
Private Sub BusinessName_AfterUpdate()
' If BusinessName = Duke, then fill in "Durham" for
BusinessCity and "27710" for BusinessZip

Select Case BusinessName
Case "Duke"
BusinessCity = 12345 ' City_ID for "Durham"
BusinessZip = 27710 ' ZIP/PostalCode_ID for "27710"
End Select

End Sub
 
Sue,
This is pretty much what the other posts say with this addition...
In the case statement, use the Business ID that corresponds to "Duke" for
comparison. The value of Me!BusinessName is the first column of the combo
box, which is the Business_ID. Likewise, the BusinessCity and BusinessZip
combo boxes would be set to the City_ID for "Durham" and the
Zip/PostalCode_ID for "27710".

Private Sub BusinessName_AfterUpdate()

Select Case Me!BusinessName
Case 123 ' Business_ID for "Duke"
Me!BusinessCity = 12345 ' City_ID for "Durham"
Me!BusinessZip = 27710 ' ZIP/PostalCode_ID for "27710"
End Select

End Sub

Hope this helps,
Miki


Sue said:
Nope.
Grr.
I'm getting frustrated, but I DO appreciate your attempts to help.
 
Have you tried setting a breakpoint in your code to see if that event
really fires? Click on the "Select Case" line, and hit the F9 key.
The line will turn red. Then try updating the Business name. Also,
AfterUpdate won't fire until you hit enter or click/tab out of the
field. After you enter some data, and tab to the next field, the code
window will pop up on the "Select Case" line. If this happens, you
know the event is firing, if not well...

Another idea: Add a Case Else after your last case, like so.

Case Else
Me!BusinessCity = "Unknown"
Me!BusinessZip = "Unknown"
End Select

Also, with the form open, hit Ctrl-G (VBA Immediate window) type:
Forms!formname!BusinessCity = 12345

Insert the name of your form for "formname". Does the City field
change? Try typing:
Print Forms!formname!BusinessName

Again substituting the name of your form for "formname". Does it
print what you typed into that field?

Hope this helps,
Chris M.
 
Yippee - thanks, this was the key.
I had my code referring to the text field rather than the primary key.
Appreciate your help, all!
 
Back
Top