Using a Combo Box to Search for a Record:

A

Ayo

I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
C

Cheese_whiz

Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

Ayo said:
I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
A

Ayo

Thanks CW,
But one problem I am having is this, the first time the form open and I
change the value in the combo box, the only value that changes is the combo
box itself

Cheese_whiz said:
Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

Ayo said:
I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
C

Cheese_whiz

Hi Ayo,

Interesting. I've never run into that problem and I use this basic code
everytime I need this to work. Does it work if you make a change in the
combo box and then hit the 'enter' button on the keyboard?

In order to fire the after_update event, I believe the control has to lose
focus. Hitting enter should do it.

As an alternative, maybe try shifting the focus from the control in the
'on_dirty' event. Something like:
________________________
combobox_dirty()

Me.someOtherControl.setfocus

End Sub
________________________

(add your error handler to the above).

What version of access do you have? I think there's a combo box wizard that
will walk you through the process of setting up a combo box for this
purpose.....heck, it may even be the same code for all I know.....don't
remember where it first came from.

In 2003 version, if you open up the toolbox (alt-v, x), one of the top
buttons (in the toolbox window) is for turning the wizards on. Then you use
the combo box button on the toolbox (by clicking it) and then left-click/drag
in your form to draw the combo box. That should start the wizard. I think
it's the first screen in the wizard that lets you choose something like 'look
up records in my form based on combo box selection" or something along those
lines.

I've got 2007 but haven't done much in the way of development with it so I'm
not sure but I would expect it to have that same functionality.

Hope something here helps,
CW

Ayo said:
Thanks CW,
But one problem I am having is this, the first time the form open and I
change the value in the combo box, the only value that changes is the combo
box itself

Cheese_whiz said:
Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

Ayo said:
I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
A

Ayo

This is the situation; when the form is open for the fist time and I make a
change to the combo box, the value in the combo box changes but nothing else
on the form changes. Essentially the first change just replaces the value in
the table of the combo box value. The next time I change the value in the
combo box thing appears to be working fine. I tried
combobox_dirty()
Me.someOtherControl.setfocus
End Sub
and it only complicated things because nothing works at all.


Cheese_whiz said:
Hi Ayo,

Interesting. I've never run into that problem and I use this basic code
everytime I need this to work. Does it work if you make a change in the
combo box and then hit the 'enter' button on the keyboard?

In order to fire the after_update event, I believe the control has to lose
focus. Hitting enter should do it.

As an alternative, maybe try shifting the focus from the control in the
'on_dirty' event. Something like:
________________________
combobox_dirty()

Me.someOtherControl.setfocus

End Sub
________________________

(add your error handler to the above).

What version of access do you have? I think there's a combo box wizard that
will walk you through the process of setting up a combo box for this
purpose.....heck, it may even be the same code for all I know.....don't
remember where it first came from.

In 2003 version, if you open up the toolbox (alt-v, x), one of the top
buttons (in the toolbox window) is for turning the wizards on. Then you use
the combo box button on the toolbox (by clicking it) and then left-click/drag
in your form to draw the combo box. That should start the wizard. I think
it's the first screen in the wizard that lets you choose something like 'look
up records in my form based on combo box selection" or something along those
lines.

I've got 2007 but haven't done much in the way of development with it so I'm
not sure but I would expect it to have that same functionality.

Hope something here helps,
CW

Ayo said:
Thanks CW,
But one problem I am having is this, the first time the form open and I
change the value in the combo box, the only value that changes is the combo
box itself

Cheese_whiz said:
Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

:

I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
C

Cheese_whiz

Hi Ayo,

I've checked a more recent version of the code, and the only difference I
see between what I posted and the more recent version is that I used:
Forms!MyForm instead of 'Me' in the first and third lines of the three line
block in the code that deals with pulling up the record you choose.

So, I guess you could try changing those two lines to get rid of the
shorthand 'Me' and replace it with Forms!YourFormName......... (where
YourFormName is replaced with the name of your form).

Generally speaking, I wouldn't think it would matter, but I have seen cases
where, for whatever reason, it DOES matter.

On a related note, I didn't mean for you to include 'SomeOtherControl' in
the code you put on the 'dirty' event, if you did. That also needed to be
replaced with the name of a control on your form. I would remove that code
now anyway. It wasn't necessary in my applications and I doubt it's
necessary in yours. Something else is causing the problem.

If none of that works, then I can only speculate that you have some kind of
property for the form set that is somehow causing problems. I have used the
'Me' version of that code on 2007 version of access, and the version with the
Files!MyForm on both 2002 and 2003.

Maybe someone else will step in and clear things up. I'm no where near the
access developer that some of these other guys are.

Sorry I couldn't be of more help,
CW

Ayo said:
This is the situation; when the form is open for the fist time and I make a
change to the combo box, the value in the combo box changes but nothing else
on the form changes. Essentially the first change just replaces the value in
the table of the combo box value. The next time I change the value in the
combo box thing appears to be working fine. I tried
combobox_dirty()
Me.someOtherControl.setfocus
End Sub
and it only complicated things because nothing works at all.


Cheese_whiz said:
Hi Ayo,

Interesting. I've never run into that problem and I use this basic code
everytime I need this to work. Does it work if you make a change in the
combo box and then hit the 'enter' button on the keyboard?

In order to fire the after_update event, I believe the control has to lose
focus. Hitting enter should do it.

As an alternative, maybe try shifting the focus from the control in the
'on_dirty' event. Something like:
________________________
combobox_dirty()

Me.someOtherControl.setfocus

End Sub
________________________

(add your error handler to the above).

What version of access do you have? I think there's a combo box wizard that
will walk you through the process of setting up a combo box for this
purpose.....heck, it may even be the same code for all I know.....don't
remember where it first came from.

In 2003 version, if you open up the toolbox (alt-v, x), one of the top
buttons (in the toolbox window) is for turning the wizards on. Then you use
the combo box button on the toolbox (by clicking it) and then left-click/drag
in your form to draw the combo box. That should start the wizard. I think
it's the first screen in the wizard that lets you choose something like 'look
up records in my form based on combo box selection" or something along those
lines.

I've got 2007 but haven't done much in the way of development with it so I'm
not sure but I would expect it to have that same functionality.

Hope something here helps,
CW

Ayo said:
Thanks CW,
But one problem I am having is this, the first time the form open and I
change the value in the combo box, the only value that changes is the combo
box itself

:

Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

:

I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 
A

Ayo

Thanks CW,
But I am going to try something else that worked for me before. You were
very helpful and I am very greatful.
Thank you very much.
Ayo

Cheese_whiz said:
Hi Ayo,

I've checked a more recent version of the code, and the only difference I
see between what I posted and the more recent version is that I used:
Forms!MyForm instead of 'Me' in the first and third lines of the three line
block in the code that deals with pulling up the record you choose.

So, I guess you could try changing those two lines to get rid of the
shorthand 'Me' and replace it with Forms!YourFormName......... (where
YourFormName is replaced with the name of your form).

Generally speaking, I wouldn't think it would matter, but I have seen cases
where, for whatever reason, it DOES matter.

On a related note, I didn't mean for you to include 'SomeOtherControl' in
the code you put on the 'dirty' event, if you did. That also needed to be
replaced with the name of a control on your form. I would remove that code
now anyway. It wasn't necessary in my applications and I doubt it's
necessary in yours. Something else is causing the problem.

If none of that works, then I can only speculate that you have some kind of
property for the form set that is somehow causing problems. I have used the
'Me' version of that code on 2007 version of access, and the version with the
Files!MyForm on both 2002 and 2003.

Maybe someone else will step in and clear things up. I'm no where near the
access developer that some of these other guys are.

Sorry I couldn't be of more help,
CW

Ayo said:
This is the situation; when the form is open for the fist time and I make a
change to the combo box, the value in the combo box changes but nothing else
on the form changes. Essentially the first change just replaces the value in
the table of the combo box value. The next time I change the value in the
combo box thing appears to be working fine. I tried
combobox_dirty()
Me.someOtherControl.setfocus
End Sub
and it only complicated things because nothing works at all.


Cheese_whiz said:
Hi Ayo,

Interesting. I've never run into that problem and I use this basic code
everytime I need this to work. Does it work if you make a change in the
combo box and then hit the 'enter' button on the keyboard?

In order to fire the after_update event, I believe the control has to lose
focus. Hitting enter should do it.

As an alternative, maybe try shifting the focus from the control in the
'on_dirty' event. Something like:
________________________
combobox_dirty()

Me.someOtherControl.setfocus

End Sub
________________________

(add your error handler to the above).

What version of access do you have? I think there's a combo box wizard that
will walk you through the process of setting up a combo box for this
purpose.....heck, it may even be the same code for all I know.....don't
remember where it first came from.

In 2003 version, if you open up the toolbox (alt-v, x), one of the top
buttons (in the toolbox window) is for turning the wizards on. Then you use
the combo box button on the toolbox (by clicking it) and then left-click/drag
in your form to draw the combo box. That should start the wizard. I think
it's the first screen in the wizard that lets you choose something like 'look
up records in my form based on combo box selection" or something along those
lines.

I've got 2007 but haven't done much in the way of development with it so I'm
not sure but I would expect it to have that same functionality.

Hope something here helps,
CW

:

Thanks CW,
But one problem I am having is this, the first time the form open and I
change the value in the combo box, the only value that changes is the combo
box itself

:

Hi Ayo,

Here's some code from a combo box in one of my apps that does what you want.
As you can see, it's located in the after_update event of the combo box.
___________________________________________
Private Sub cmbQuickFile_AfterUpdate()
Dim rs As Object

On Error GoTo cmbQuickFile_AfterUpdate_Error

If Me.Dirty Then
If MsgBox("Save changes to current record before moving to new
record?", vbYesNo, _
"Save changes?") = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
End If

Set rs = Forms!Files.Recordset.Clone
rs.FindFirst "[ID] = " & Me![cmbQuickFile]
If Not rs.EOF Then Forms!Files.Bookmark = rs.Bookmark


Exit_cmbQuickFile_AfterUpdate:
Exit Sub

cmbQuickFile_AfterUpdate_Error:
Call LogError(Err.Number, Err.Description, "cmbQuickFile_AfterUpdate",
Forms!Files.Name, , True)

End Sub
__________________________________________________

The msgbox line in the early part of the code is really one line. It
shouldn't have returned like it did above. If you make it one line in your
code, remove that underscore from it.

The above code includes a check to see if the record has been modified, and
if so, asks the user if they want to save it.

The rowsource for the combo box is a select query that, most importantly,
includes the primary key from the query that populates the form (IssuesQuery)
in question. In addition, it has a couple of fields that my users use to
identify the records (since they will not see the primary key field in the
combo box and wouldn't know how to associate it with a record even if they
did). The select query looks something like this:

Select CaseID, CaseName, CaseNumber from IssuesQuery Order by CaseName,
CaseNumber; In my case, users type in the caseName into the combo box to
find the records. I'm not altogether pleased with that arrangement (since
two cases can have the same name), but since not all cases have case
numbers.....I didn't see a better alternative.

You need to set the column count in the properties window for the combo box
to the appropriate number (3 in my case), and also set the column widths so
that the primary key (CaseID in my example) is not viewable, but the other
fields are. In my example, the column widths are: 0;1";1"

That code should work for you as long as you change all the names to reflect
your application.

I hope that helps,
CW

:

I have a form and on the form there is a combo box. The form also contains
lots of text boxes. What I want to do is select a value in the combo box and
have the form display the record of the selection in the combo box. I was
using this code:
DoCmd.ShowAllRecords
Me!txtSiteNumber.SetFocus
DoCmd.FindRecord Me!cboSiteNumber
in the AfterUpdate event of the combo box, but all it does is change the
value in the txtSiteNumber. I also tried:
DoCmd.OpenForm Me.Name,,, "[Site Number]='" & Me.cmbSiteNumber.Column
(0) & "'" & ""
with the same result.
Any ideas what I am doing wrong? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Setting a combo box value 8
Combo Box 3
Combo Box Help 7
Combo Box and First Record 5
Combo Box Question 4
Change displayed combo box value using VBA 4
Combo box question 7
change a Field into a Combo Box 9

Top