By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

strange Combo Behavior

P: n/a
I have a simple form with a combo box on top and then when a record is
chosen the remaining 3 fields from the table on the form.

My problem is that if I open the form on its own, all is fine. I see
the record I wanted and when I change the record in the drop-down, the
data fields that go with that record are displayed.

HOWEVER, when I open the form as the result of the user double-clicking
a record from the main form's list box, that chosen record is displayed
fine, but the drop-down box doesn't work anymore! If I choose another
ad from the combo-box drop-down, that ad shows in the combo, but the
data on the bottom of the form never changes.

I have no idea why this is happening, and didn't see any similar posts.
Maybe I have something set up in the form wrong?

Code:
Form:
Private Sub cboChooseAd_AfterUpdate()

' User can choose an Ad to view (if double click from Main form, shows
that ad)
' Find the record that matches the control.

Dim rs As Object
Dim lngAdKey As Long

lngAdKey = Me.cboChooseAd

Set rs = Me.Recordset.Clone
rs.FindFirst "[AdKey] = " & lngAdKey
Me.Bookmark = rs.Bookmark

End Sub
Callling form:
If IsNull(Me.lstAds.Column(0)) Then
MsgBox "Please choose an ad to view", , "Ads - Choose an Ad"
GoTo Err_lstAds_DblClick
Else
lngAdKey = Me.lstAds.Column(0)
End If

strLinkCriteria = "[AdKey]=" & lngAdKey

strDocName = "frmAdDetails"
DoCmd.OpenForm strDocName, , , strLinkCriteria

Forms!frmAdDetails.cboChooseAd = lngAdKey
HELP!!!
Thanks
sara

May 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"sara" <sa*******@yahoo.com> wrote in
news:11**********************@j55g2000cwa.googlegr oups.com:
I have a simple form with a combo box on top and then when a
record is chosen the remaining 3 fields from the table on the
form.

My problem is that if I open the form on its own, all is fine.
I see the record I wanted and when I change the record in the
drop-down, the data fields that go with that record are
displayed.

HOWEVER, when I open the form as the result of the user
double-clicking a record from the main form's list box, that
chosen record is displayed fine, but the drop-down box doesn't
work anymore! If I choose another ad from the combo-box
drop-down, that ad shows in the combo, but the data on the
bottom of the form never changes.

I have no idea why this is happening, and didn't see any
similar posts.
Maybe I have something set up in the form wrong?
Code:
Form:
Private Sub cboChooseAd_AfterUpdate()

' User can choose an Ad to view (if double click from Main
form, shows that ad)
' Find the record that matches the control.

Dim rs As Object
Dim lngAdKey As Long

lngAdKey = Me.cboChooseAd

Set rs = Me.Recordset.Clone
rs.FindFirst "[AdKey] = " & lngAdKey
Me.Bookmark = rs.Bookmark

End Sub
Callling form:
If IsNull(Me.lstAds.Column(0)) Then
MsgBox "Please choose an ad to view", , "Ads - Choose
an Ad" GoTo Err_lstAds_DblClick
Else
lngAdKey = Me.lstAds.Column(0)
End If

strLinkCriteria = "[AdKey]=" & lngAdKey

strDocName = "frmAdDetails"
DoCmd.OpenForm strDocName, , , strLinkCriteria

Forms!frmAdDetails.cboChooseAd = lngAdKey
HELP!!!
Thanks
sara


When you open the form by double-clicking, the form's recordset
is filtered to include only the record(s) which meet the
criteria. You might want to open the form without the
strLinkCriteria parameter, but execute the findfirst method
after the form opens

DoCmd.OpenForm strDocName '<--------existing

Dim rs as recordset
Set rs = Forms!frmAdDetails.Recordset.Clone
rs.FindFirst "[AdKey] = " & lngAdKey
Forms!frmAdDetails.Bookmark = rs.Bookmark

Forms!frmAdDetails.cboChooseAd = lngAdKey '<--existing

--
Bob Quintal

PA is y I've altered my email address.
May 20 '06 #2

P: n/a
Got it! Thanks so much for the help. It took me a while, but all is
working now.

Sara

May 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.