DELETE A VALUE VIA CODE

F

FARAZ QURESHI

I have two cascading combo boxes "Country" (Unbound) & "City".
How can I have the "City" field be deleted or converted to "NULL" upon any
change in the current value of "Country"?
 
F

FARAZ QURESHI

Thanx Allen!
U R the greatest!
Could u please also help me in forming a complete code as the Country Combo
Box already has an update event attached for City filteration like:

Private Sub Country_AfterUpdate()
On Error Resume Next
City.RowSource = "Select Table1.City " & _
"FROM Table1 " & _
"WHERE Table1.Country = '" & Country.Value & "' " & _
"ORDER BY Table1.City;"
End Sub

Thanx again for your usual prompt response.

--
Best Regards,
FARAZ A. QURESHI


Allen Browne said:
Private Sub Country_AfterUpdate()
Me.City = Null
End Sub
 
A

Allen Browne

Have a go, Faraz.

I think you can take the one line I suggested, and put it into the code you
already have, on a line of its own.

BTW, I don't think it's a good idea to use:
On Error Resume Next
Although this will suppress any error, it's like smashing all the warning
lights on the dash of your car. If a problem arises you won't know about it.
 
F

FARAZ QURESHI

Thanx Allen!
No doubt an xclent suggestion, to save headlights!
However, what is "Me.City?"

What would the new code be:

Private Sub Country_AfterUpdate()
City = Null
<OR>
Me.City = Null
<OR>
Table1.City = Null
City.RowSource = "Select Table1.City " & _
"FROM Table1 " & _
"WHERE Table1.Country = '" & Country.Value & "' " & _
"ORDER BY Table1.City;"
End Sub

What's
 
A

Allen Browne

Me is a short way of referring to the form.
So if the fomrm is called Form1, it's functionally equivalent to:
Forms!Form1

Therefore:
Me.City
refers to a text box (or combo?) named City on the current form.
It will work if you just use:
City
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Inter-Dependent Fields 9
FIELD BASED FILTERATIONS 1
Lookup 2
Countries, zips and cities 23
Connecting combo boxes 1
Filter On Condition 1
Cascading Combo Boxes - HELP PLEASE!!!!!! 5
First entry in combo 7

Top