Re: Combo box problem

message from =?Utf-8?B?QW5uYQ==?= on 18 May 2004
I tried to re-bind the control but the same problem still happens.
 
Jeff Boyce replied to =?Utf-8?B?QW5uYQ==?= on 19 May 2004
Anna

What do you mean (what is your definition of) when you say "re-bind the
control" -- we may not mean the same thing with that phrase.

Jeff Boyce
<Access MVP>
 
=?Utf-8?B?QW5uYQ==?= replied to Jeff Boyce on 24 May 2004
It didn't have a control source so I specified the control source which is the employee name from the employee table. But it still does not work properly. No matter who you select in the combo box the text box only displays the name of the first person you selected.
 
John Vinson replied to =?Utf-8?B?QW5uYQ==?= on 24 May 2004
The Control Source should - MUST! - be blank. What's happening is that
you are overwriting the name in the first record with whichever record
you select.

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
=?Utf-8?B?QW5uYQ==?= replied to John Vinson on 25 May 2004
John,

When I had the control source blank it still was overwriting the record. You described the problem exactly, it is overwriting the name in the first record with the record selected. How do I fix this database from doing that?
 
John Vinson replied to =?Utf-8?B?QW5uYQ==?= on 25 May 2004
Please post your code. A blank Control Source - an unbound combo box -
cannot overwrite anything; there's something else going on!

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
=?Utf-8?B?QW5uYQ==?= replied to John Vinson on 26 May 2004
Option Compare Database
Private Sub Button28_Click()
End Sub
Private Sub Detail0_Click()
End Sub
Private Sub LastName_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub NewHrsMissd_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub NewHrsWkd_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub PayrollNo_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Text12_Click()
End Sub
Private Sub Text13_Click()
End Sub
Private Sub WorkGroup_BeforeUpdate(Cancel As Integer)
End Sub
 
John Vinson replied to =?Utf-8?B?QW5uYQ==?= on 26 May 2004
Ummmm... none of these do ANYTHING AT ALL. They should all be deleted,
no point in having an event which is in fact a non-event!

Perhaps I'm misunderstanding this combo box entirely. What do you
want/expect the combo box to do? What are its RowSource,
ControlSource, and Bound Column properties? If you want the combo to
find a record and display it, the combo's AfterUpdate event should
have either some VBA code or a macro to cause that to happen - does
it?

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
=?Utf-8?B?QW5uYQ==?= replied to John Vinson on 26 May 2004
The row source is: Select [PayrollNo] From [Employees];
The control source is blank
The bound column is: 1

What it is supposed to do is when you click on the combo box for PayrollNo it should display the person's first name, last name and workgroup in text boxes. But it just keeps overwriting the first record.
 
John Vinson replied to =?Utf-8?B?QW5uYQ==?= on 27 May 2004
Ummmm... No. Combo boxes are not magical; an unbound combo box with no
code will not overwrite anything, nor will it find any record, nor
will it display anything.

You would need to have VBA code in the Combo Box's AfterUpdate event
like (making guesses at the structure of your form and table here):

Private Sub cboPayrollNo_AfterUpdate()
Dim rs As DAO.Recordset
' Open a Recordset based on the Form's Recordsource
Set rs = Me.RecordsetClone
' Find the selected PayrollNo; I assume it's a Text field,
' if it's not leave off the ' characters
rs.FindFirst "[PayrollNo] = '" & Me!cboPayrollNo & "'"
If rs.NoMatch Then
' Warn the user and go to the first record if not found
MsgBox "This employee was not found", vbOKOnly
rs.MoveFirst
End If
Me.Bookmark = rs.Bookmark ' synch the form to the recordset
End Sub

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 

Archived message: Re: Combo box problem (Microsoft Access Forms)