English 中文(简体)
Reading data from a table (newbie MS Access)
原标题:

I realize the newbieness of this question, but google searches are not helping me.

I ve created an MS Access database and am trying to automatically update a cell in a row when another cell is updated with data from a drop-down menu. I ve created a sub "afterupdate" for the text box in the form, and can simply create a "select case" to update the cell based on what value is entered.

However, the Select Case would be very long, and I already have the list of values populated in another table in the database. Is there a way to set the value of the new cell to whatever the corresponding value is?

Example:

Table 1:

Mode --- Time

A --------- 1:00

B --------- 2:00

C --------- 4:00

So, in my form, when I select "A" for one cell, another cell would automatically update with the information "1:00". Again, "Select Case" works, I am wondering if there is a faster way.

问题回答

If you wish to do this in a form, lets try

  • Create a form with a combo box called cmbMode.
  • On the Properties/Data change Row Source to SELECT * FROM tblModes.
  • On the Properties/Format change Column Count to 2.
  • On the Propeties/Format change Column Widths to 3,0
  • Create a Text box called txtTime.
  • On the Properties/Data change Control Source to =[cmbMode].[Column] (1).

That should auto update on change.

EDIT

Just as an after thought, this will not update values to a table, as the text box will not be bound to a field.

You could change the combo box AFTER_UPDATE event to use (if the textbox is bound to the TIME field) to use

Time.Value = cmbMode.Column(1)




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签