2

I am using Access 2010 to create a database of fish caught by local fishermen. I have a table with all the information about each fish caught (location, day, length, etc) and a form to add new records to that table. I am trying to automate as much of the data entry as possible because we have many interns that will be entering data throughout the summer. The more I can have the program do, the more I can limit mistakes in data entry.

I would like to store the length data in metric (mm), however most of the fishermen report the lengths of the fish they catch in inches. I don't care to have length twice in my database, one metric and one imperial.

Is there a way I can have a box on the form that someone can enter the length in inches and this value is converted to metric and used to fill in the length field on the table? The trick is that sometimes the fish length is reported in metric, so I need to be able to directly input metric into the form too.

I'm guessing this is either not possible or already somewhere & I am not using the right key words in my searches. I appreciate anyone who can point me in the right direction.

Thanks!

4

2 回答 2

2

After Update输入测量值的控件中,假设控件被调用Length

您可以使用此代码在 vba 中更改它。

Me.length = me.length * 25.4

这是执行此操作的众多方法之一

于 2013-06-13T17:28:35.863 回答
2

这是一种方法。它类似于 Scotch 的,但有一些改进。

有2个文本框。毫米和英寸尺寸各 1 个。
Milimeters 文本框通过 Control Source 绑定到表格,因此其中输入的内容就是保存在数据库中的内容。英寸文本框未绑定。但是输入到该文本框中的内容会被转换,并且新值会被放入毫米文本框中。代码如下所示:

Private Sub txtSizeIn_AfterUpdate()
   Me.txtSizeMM = Me.txtSizeIn * 25.4
End Sub

这样,渔民就可以选择使用什么测量方法。

于 2013-06-13T18:21:14.017 回答