Bind fields to selected article in MS Access

i have a simple question, i hope ^^

I have a combobox "Article" and a textfield "Description". After selecting a article OR loading the form with the pre selection i want to show the description of the selected article in the description field.

How i can do this?

Bind fields to selected article in MS Access

I would like a simple "Article.Description" or "[Article].[Description]" and MS Access do the rest. But it doesnt work i think. So i try to build a event handler for selecting another article to read the description manually - but it doesnt work.

Thanks in Advance for any idea!

-------------Problems Reply------------

It somewhat depends upon where you are storing the Article and Description data.

Being generic:

Set the "Rowsource" for "Article" to something like this (where Table1 is your table holding the values)

SELECT Table1.Article, Table1.Description FROM Table1;

Make sure that the following properties are set for the Article control (these are their defaults)

Bound Column = 1
Column Count = 1

On the "After Update" event for the Article combo box enter this Event Procedure:

Me.Description = Me.Article.Column(1)

This will update the description field with the corresponding article description.

With the answer from josh i could fix the problem.

Thats the new query for the article box.

SELECT [Number] & " - " & [Name] AS Article, Article.Id, Article.Description FROM Article;

With settings.

Bound Column: 2
Column count: 2
Column width: 4cm;0cm

And then the VBA script.

Private Sub Article_AfterUpdate()
DescriptionField.Value = Article.Column(2)
End Sub

Private Sub Form_Current()
End Sub

I'm using "Form_Current()" ("Form on Show") because if i use the buttons to switch the dataset i want to update the description. If i wouldnt do this i have an empty or wrong description. Or is there another way to make this better?

Category:ms access Views:1 Time:2017-09-12

Related post

Copyright (C), All Rights Reserved.

processed in 0.172 (s). 11 q(s)