combobox & Subform

K

Karen53

Hi,

I'm having trouble with this. I found a previous post and thought I had the
answer but am still having trouble.

I have an unbound combobox looking up a list. Once a selection is made I
have code to pull the value of the unbound combobox into a bound textbox.

This much works. When I change the combobox value the textbox changes
approriately.

I have a sub form to display all of the related information to the choice on
the list. The subform has parent link and child link set to the bound value
of the text box. My problem is the sub form does not update to reflect the
change. Also, when I try to go to design mode or close the form I get an
error message it can't be saved because it would create duplicate index,
primary key, etc.

Option Compare Database

Private Sub cboMovieTitle_AfterUpdate()

Me.txtmovieID = Me.cboMovieTitle

End Sub

since it wasn't updating, I tried this...

added to movieID on query
[forms]![frmEditMovies]![txtmovieID]

code
Private Sub txtmovieID_Change()

Me.Requery

End Sub
 
B

Beetle

What are you trying to do? If you're trying to find a record on your form
based on the value selected in the combo box, then you're going about it
the wrong way. You don't want to actually change the value of the bound
MovieID text box, you just want to *find* the record with the matching ID.

The After Update event of your combo box should have code like this;

With Me.RecordsetClone
.FindFirst "[MovieID]=" & Me.YourComboBox
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
--
_________

Sean Bailey


Karen53 said:
Hi,

No, I got it to work all on one form but how do I link it to a sub form?
--
Thanks for your help.
Karen53


Karen53 said:
Hi,

I'm having trouble with this. I found a previous post and thought I had the
answer but am still having trouble.

I have an unbound combobox looking up a list. Once a selection is made I
have code to pull the value of the unbound combobox into a bound textbox.

This much works. When I change the combobox value the textbox changes
approriately.

I have a sub form to display all of the related information to the choice on
the list. The subform has parent link and child link set to the bound value
of the text box. My problem is the sub form does not update to reflect the
change. Also, when I try to go to design mode or close the form I get an
error message it can't be saved because it would create duplicate index,
primary key, etc.

Option Compare Database

Private Sub cboMovieTitle_AfterUpdate()

Me.txtmovieID = Me.cboMovieTitle

End Sub

since it wasn't updating, I tried this...

added to movieID on query
[forms]![frmEditMovies]![txtmovieID]

code
Private Sub txtmovieID_Change()

Me.Requery

End Sub
 
K

Karen53

Thank you beetle

--
Thanks for your help.
Karen53


Beetle said:
What are you trying to do? If you're trying to find a record on your form
based on the value selected in the combo box, then you're going about it
the wrong way. You don't want to actually change the value of the bound
MovieID text box, you just want to *find* the record with the matching ID.

The After Update event of your combo box should have code like this;

With Me.RecordsetClone
.FindFirst "[MovieID]=" & Me.YourComboBox
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
--
_________

Sean Bailey


Karen53 said:
Hi,

No, I got it to work all on one form but how do I link it to a sub form?
--
Thanks for your help.
Karen53


Karen53 said:
Hi,

I'm having trouble with this. I found a previous post and thought I had the
answer but am still having trouble.

I have an unbound combobox looking up a list. Once a selection is made I
have code to pull the value of the unbound combobox into a bound textbox.

This much works. When I change the combobox value the textbox changes
approriately.

I have a sub form to display all of the related information to the choice on
the list. The subform has parent link and child link set to the bound value
of the text box. My problem is the sub form does not update to reflect the
change. Also, when I try to go to design mode or close the form I get an
error message it can't be saved because it would create duplicate index,
primary key, etc.

Option Compare Database

Private Sub cboMovieTitle_AfterUpdate()

Me.txtmovieID = Me.cboMovieTitle

End Sub

since it wasn't updating, I tried this...

added to movieID on query
[forms]![frmEditMovies]![txtmovieID]

code
Private Sub txtmovieID_Change()

Me.Requery

End Sub
 

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