Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Open the VBA window and click in the left margin of the code. It will put a red dot in the margin. This is called a "break point". Run your form and make your change, and the code will stop where the break point is and highlight that line in yellow. To continue running through the code, press F8. This will run the lines of code one at a time and allow you to see exactly what's being processed. </p> <p>When you get to each line of code, "hover" your mouse over the variables from the current and previous lines to see what the application THINKS the variable is equal to. You may find that what you think and what the app thinks are two different things at times.</p> <p>If the code jumps over a bunch of lines and goes straight to the End Sub, you've got an error on the last line it highlighted.</p> <p>Using this methodology is PARAMOUNT to understanding how VBA works. I've been working with it for 20 years and I still do this when I can't figure out what's wrong. See if this helps you answer your own question. If not, hopefully it will at least pinpoint a line of code that's not working properly and you can come back and ask a specific question about it.</p> <p>EDIT: A quick look at the code makes me wonder something; is City_No a NUMBER or a TEXT? Because if it's a NUMBER, you want to get rid of the single quote around the variable. Text needs single quotes, numbers don't.</p> <p>FURTHER EDIT: I think you need something more like this:</p> <pre><code>Private Sub city_no_AfterUpdate() Dim got_city_nm, got_state_nm got_city_nm = DLookup("city_nm", "city_table", "city_no='" &amp; Me.city_no &amp; "'") Me.city_nm.Value = got_city_nm got_state_nm = DLookup("state_nm", "city_table", "city_no='" &amp; Me.city_no &amp; "'") Me.state_nm.Value = got_state_nm seat_no = "XXX" End Sub </code></pre> <p>If you're trying to fill in the value of a control (i.e. textbox), you need to reference it with "Me." (if it's on the same form) or "Forms!MyFormName." (if it's on another form).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload