Synchronize Combo with TextBox

  • Thread starter chopper7898 via AccessMonster.com
  • Start date
C

chopper7898 via AccessMonster.com

I have a MainForm with a text box for ProjectTitle which uses cmdbuttons to
navigate and add new record. I want to also use a combo so you can see the
ProjectTitles.

On the MainForm is a subform that show Daily Reports related to the
ProjectTitle, It took me along time just to get the combo and textbox on the
MainForm working so they both will show the last record on the subform when
they are used. I can select the Project from both.

When I select from the combo the textbox goes to the same ProjectTitle.
When I use the Textbox with cmdbutton the combo doesn't change.

I want the Combo to be Synchronize with the ProjectTilte textbox when it
changes.
How would I accomplish this?

I'm using 2007
 
J

Jeanette Cunningham

Hi
this code:
Me.[NameOfCombo] = Me.[NameOfPKField]

will set the combo to the same record that the form is on.
Assuming that the combo has its first column hidden with the primary key
value of the form's record source.
Also assuming that the Form's record source has a primary key, all you need
to do to is tell the combo to move to the record with the same primary key
value as the primary key value for the form.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

chopper7898 via AccessMonster.com

Jeanette said:
Hi
this code:
Me.[NameOfCombo] = Me.[NameOfPKField]

will set the combo to the same record that the form is on.
Assuming that the combo has its first column hidden with the primary key
value of the form's record source.
Also assuming that the Form's record source has a primary key, all you need
to do to is tell the combo to move to the record with the same primary key
value as the primary key value for the form.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I have a MainForm with a text box for ProjectTitle which uses cmdbuttons to
navigate and add new record. I want to also use a combo so you can see
[quoted text clipped - 16 lines]
I'm using 2007


Would that go in with the AfterUpdate Event
This is what I have now and the combo makes the subform go to the last record.



Private Sub cboSelectProject_AfterUpdate()
Dim Rst As DAO.Recordset
Set Rst = Me.RecordsetClone
Rst.FindFirst "[ProjectID] = " & Me!cboSelectProject
Me.Bookmark = Rst.Bookmark
Rst.Close
Set Rst = Nothing
End Sub
 
J

Jeanette Cunningham

I am assuming that when the cmd button is clicked, the form moves to the
record with the primary key for the project title typed in the text box.
Is this what happens on your form?
If the cmd button makes the main form move to the record for the title
chosen, then in the code for the cmd button, as the last step of its code,
put:
Me.[NameOfCombo] = Me.[NameOfPKField]

The way you have set up your form is a little unusual.

With access, it is very common to use a combo to navigate (aka a search
form) and to have a separate button to open another form to add a new
record.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


chopper7898 via AccessMonster.com said:
Jeanette said:
Hi
this code:
Me.[NameOfCombo] = Me.[NameOfPKField]

will set the combo to the same record that the form is on.
Assuming that the combo has its first column hidden with the primary key
value of the form's record source.
Also assuming that the Form's record source has a primary key, all you
need
to do to is tell the combo to move to the record with the same primary key
value as the primary key value for the form.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I have a MainForm with a text box for ProjectTitle which uses cmdbuttons
to
navigate and add new record. I want to also use a combo so you can see
[quoted text clipped - 16 lines]
I'm using 2007


Would that go in with the AfterUpdate Event
This is what I have now and the combo makes the subform go to the last
record.



Private Sub cboSelectProject_AfterUpdate()
Dim Rst As DAO.Recordset
Set Rst = Me.RecordsetClone
Rst.FindFirst "[ProjectID] = " & Me!cboSelectProject
Me.Bookmark = Rst.Bookmark
Rst.Close
Set Rst = Nothing
End Sub
 
C

chopper7898 via AccessMonster.com

Jeanette said:
I am assuming that when the cmd button is clicked, the form moves to the
record with the primary key for the project title typed in the text box.
Is this what happens on your form?
If the cmd button makes the main form move to the record for the title
chosen, then in the code for the cmd button, as the last step of its code,
put:
Me.[NameOfCombo] = Me.[NameOfPKField]

The way you have set up your form is a little unusual.

With access, it is very common to use a combo to navigate (aka a search
form) and to have a separate button to open another form to add a new
record.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
[quoted text clipped - 29 lines]
Set Rst = Nothing
End Sub

I got it, just in time, thanks a lot!
I put the code in the MainForm event Current and it works.
thanks again.
 

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

Top