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

Problem opening form with selection

P: n/a
Really wierd problem opening a form with selection.

I use this code on a button:

On Error GoTo Err_Command8_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_ADv5"

If Forms!frm_ADv5_List!keyADv5 <0 Then
stLinkCriteria = "((keyADv5 = " & Me.keyADv5 & "))"

DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
End If

Exit_Command8_Click:

I know the code is going through the first part of the IF condition.

The stLinkCriteria = ((keyADv5 = 14))

When I click on the icon, it opens up the form, but a blank form. The
filter icon is highlighted. If I mouse over, it says "Remove FIlter".
If I click on it, then form then displays the proper filtered record.

I checked in Design mode the form, after it was opened,and it has Allow
Filters = YES and Filter = ((keyADv5 = 14))

This is wierd. I have used similar code before without any problems.

What am I missing? Hopefully something simple.

Bob
Jul 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try this

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_ADv5"

Me.keyADv5.SetFocus

If Me.KeyADv5<>0 Then
stLinkCriteria = "[keyADv5]=" & Me.keyADv5
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , , acFormAdd
End If

Jul 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.