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

Resetting LinkCriteria after opening form.

P: 6
Hi,

I was wondering if anyone could help?!

I have a button on one form (Participant form) that opens another form at a specific record (Learning Session form with specific session for that participant). After opening to that specific learning session I can't move to a different learning session. I was wondering if there was someway to 'reset' the LinkCriteria so that the Learning Session form can move between records.

Sorry if this is confusing, but any help would be greatly appreciated.

Thanks!

Kira
Nov 6 '07 #1
Share this Question
Share on Google+
7 Replies


JustJim
Expert 100+
P: 407
Hi,

I was wondering if anyone could help?!

I have a button on one form (Participant form) that opens another form at a specific record (Learning Session form with specific session for that participant). After opening to that specific learning session I can't move to a different learning session. I was wondering if there was someway to 'reset' the LinkCriteria so that the Learning Session form can move between records.

Sorry if this is confusing, but any help would be greatly appreciated.

Thanks!

Kira
Hi,

I presume since you use the term LinkCriteria, that you used the wizard to make a button and you ended up with something very like this...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. On Error GoTo Err_Command0_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frmTest"
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9.  
  10. Exit_Command0_Click:
  11.     Exit Sub
  12.  
  13. Err_Command0_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_Command0_Click
  16.  
  17. End Sub
and that you have assigned stLinkCriteria to a valid Where statement (which the silly wizard doesn't do).

You will then open your form with the underlying records filtered by the Where statement in stLinkCriteria. To see all records, un-click the Apply Filter button on the toolbar.

Does that help?

Jim
Nov 7 '07 #2

P: 6
Hi,

I presume since you use the term LinkCriteria, that you used the wizard to make a button and you ended up with something very like this...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. On Error GoTo Err_Command0_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frmTest"
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9.  
  10. Exit_Command0_Click:
  11.     Exit Sub
  12.  
  13. Err_Command0_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_Command0_Click
  16.  
  17. End Sub
and that you have assigned stLinkCriteria to a valid Where statement (which the silly wizard doesn't do).

You will then open your form with the underlying records filtered by the Where statement in stLinkCriteria. To see all records, un-click the Apply Filter button on the toolbar.

Does that help?

Jim
Thanks Jim, that does help. I was wondering if there is a way to automatically have that filtered turned off every time that form is opened (so that the user doesn't have to un-click the apply filter button)?

Thanks again!
Nov 8 '07 #3

JustJim
Expert 100+
P: 407
Thanks Jim, that does help. I was wondering if there is a way to automatically have that filtered turned off every time that form is opened (so that the user doesn't have to un-click the apply filter button)?

Thanks again!
Just don't use the Where (stLinkCriteria) phrase when opening the form.

Jim
Nov 11 '07 #4

P: 6
Just don't use the Where (stLinkCriteria) phrase when opening the form.

Jim
Hi Jim,

The problem is that I want the form to open to a specific record, but then I want the user to be able to move to other records. I've tried using the following code and it won't work for some reason:

If ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = False
End If

Any suggestions?

Thanks,
Kira
Nov 13 '07 #5

JustJim
Expert 100+
P: 407
Hi Jim,

The problem is that I want the form to open to a specific record, but then I want the user to be able to move to other records. I've tried using the following code and it won't work for some reason:

If ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = False
End If

Any suggestions?

Thanks,
Kira
Hi,
This is probably pretty clunky (I haven't had my second coffee yet) but...

The button on the form which opens the target form should have something like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnOpen_Click()
  2. Dim strSearch As String
  3. strSearch = "Surname = '" & Me.txtSearch.Value & "'"
  4. DoCmd.OpenForm "frmTarget", , , , , , strSearch
  5. End Sub
where txtSearch is a text box on that form into which the operator types the person's name or whatever that you want the other form to open with. This opens the second form (frmTarget here but change the code to suit) and the strSearch after the long row of commas puts something like Surname = 'Smith' as the OpenArgs for the second form. OpenArgs (or Tag) is a handy way to pass information between forms, reports etc.

The second form should have in it's On Open event
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim rsClone As DAO.Recordset
  3. Dim strSearch As String
  4.  
  5. Set rsClone = Me.RecordsetClone
  6. strSearch = Me.OpenArgs
  7. rsClone.FindFirst strSearch
  8. If Not rsClone.NoMatch Then
  9.     Me.Bookmark = rsClone.Bookmark
  10. End If
  11. End Sub
Which should do the trick. (you might want to put an Else clause in the If statement to show a message box explaining that the string wasn't found)

Jim
ps ActiveSheet etc is Excel stuff!
Nov 14 '07 #6

P: 38
when the form loads try

Expand|Select|Wrap|Line Numbers
  1. Me.FilterOn = False
does the same thing as the filter button on the top menu

or add a button that executes this code to clear the filter, or use it on the open event
or
[code]
If Me.FilterON = True then
Me.FilterON = False
End If

You see where im going with this, have a play around with it to find the best place to put the code
Nov 15 '07 #7

P: 6
Thank you both for your help, I finally figured it out!!

Cheers
Kira
Nov 15 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.