Continuous Form Field Problem

Cavman

Registered User.
Local time
Today, 07:42
Joined
Oct 25, 2012
Messages
66
Hi,

I have a continuous form with a button next to each record. I want to open up a pop-up form that relates to that record when the button is clicked. I have all the correct code in place and the form should open filtered by the contents of the ProjectName filed.

However, when the button is clicked, it always filters by the first record only! I've put a messagebox in the button click event to display the content of the ProjectName field and it always shows the content of the first record, whichever record button you click on.

Antyone have any idea why it might be doing this? Any help would be appreciated!

Thanks,

Simon
 
The Popup Form's Record Source will be a Query that uses the Project Name field as reference in the Criteria, to filter the record for the popup Form corresponding to the current record on the Continuous Form.

When the current record on the Continuous Form is changed the Popup Form Query will not automatically Synchronize with the change.

On the Button-Click Event Procedure add a line of Code: Me.Refresh

This will inform the change on the Continuous Form to the Popup Form Source Query and will filter the correct record for the popup form.

Check this link for a different method:Synchronized Floating Popup Form
 
Last edited:
Thanks for your reply!

I already have a refresh in there, but it's still not updating. Here's the code on my button click:

Code:
 Private Sub ctlEditButton_Click()
 
Me.Refresh
MsgBox "Project Name = " & ctlProjectNameTxt
 
DoCmd.OpenForm "frmEditProjectWizard", , , "ProjectName = '" & Me.ctlProjectNameTxt & "'"
 
End Sub

I don't have a query in the record source on the popup form - I'm just using the .OpenForm command to filter the form. But the problem is obviously occuring before we even reach that part as my messagebox is still showing the first record field rather than the correct info for the one that's been clicked! Any further thoughts?

Thanks,

Simon
 
Here is another way to accomplish what you want:
Put a control on the pop up form with the index field from the main form. Set the visible property to "False".
Now you will see only the records related to the main form.
Also I would set the model property to true so you can not go back to the main form until you close the pop up.

If you have a problem with this let me know, I have a few samples I can upload.
 
Cavman, you code looks ok.
I've made an example, which is attached as a picture, (it does exactly the same a you want to do), the code behind the button is showed below.
Code:
Private Sub Kommandoknap21_Click()
  Me.Refresh
  MsgBox DateDay
End Sub

Insert " MsgBox Me.CurrentRecord" in the sub, the number showed should change each time you choose an other record..

I nearly don't dare to ask the question, but are you sure that "ctlProjectNameTxt" is the right fieldname? :)
 

Attachments

  • CurrentRecord.jpg
    CurrentRecord.jpg
    79.7 KB · Views: 199
There's definitely something strange happening! Yes, I've checked and it is the correct field name - I've questioned myself a few times and had to double check!
I've inserted a MsgBox Me.CurrentRecord into the button code and it always displays record 1, no matter which record I click on.

The code for this is so simple, I just can't understand why it's not working! :banghead:

Question: The records displayed in the continuous subform are filtered by case when either of a group of 2 radio buttons are selected on the parent form (see attached screenshot). Could this cause the problem I'm having?
 

Attachments

  • ScreenShot.JPG
    ScreenShot.JPG
    70.3 KB · Views: 201
1. Try removing the Me.Refresh
2. Try also opening the subform without the main form, (and without the filter).
3. Make a new temp form and put a button and the code in it.
 
ok, JHB, we're on the same wavelength! I've already rebuilt the subform from scratch and removed all the filtering and the refresh is also gone, but still the same issue! There's no other code on the subform. See attached for result...
 

Attachments

  • ScreenShot.JPG
    ScreenShot.JPG
    28.8 KB · Views: 181
I've fixed it! Sorry guys, it was the button. Well, it wasn't actually a button - it was an image with code in the 'click' event that was being used as a button. There must be a property in a proper button ctl that causes the current record info to be used rather than the first record. I new it must be something simple! Does anyone know the logic behind this - I obviously have a gap in my knowledge that needs updating!
 

Users who are viewing this thread

Back
Top Bottom