Solved

stLinkCriteria

Posted on 2004-08-18
14
4,962 Views
Last Modified: 2011-08-18
Hello all. This one will be simple to you guys but it's driving me totally nuts. I have a Clients Form that has a Command Button to open an Admissions Form. To filter the record being entered into the Admissions Form to be the same UniqueID as the current record in the Client Form I've added "  stLinkCriteria = "[UniqueID]=" & Me![UniqueID]" in the On Click event of the Command Button. The complete code is:

Private Sub Command134_Click()
On Error GoTo Err_Command134_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Admissions"
     stLinkCriteria = "[UniqueID]=" & Me![UniqueID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command134_Click:
    Exit Sub

Err_Command134_Click:
    MsgBox Err.Description
    Resume Exit_Command134_Click
   
End Sub

Simple right? Then in the Default Value property of the UniqueID field on the Admissions Form I've added
"=[Forms]![Clients]![UniqueID]". My problem is that when I click the button to open the Admissions Form I get a message box prompting me to "Enter Parameter Value" and the correct UniqueID is showing. I've done this a hundred times and have never had this stupid message box appear. How do I get rid of this? Thanks, Jordan.
0
Comment
Question by:JordanKingsley
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 5

Expert Comment

by:Emanon_Consulting
Comment Utility
You should only need the stLinkCriteria to link the forms.

You should be able to delete the "=[Forms]![Clients]![UniqueID]".   I don't think you need this and it may be what is giving you the error.

Cheers
M
0
 

Author Comment

by:JordanKingsley
Comment Utility
Regardless of if it's there or not I'm getting that prompt. I have 5 other applications set up the exact same way and none of them give the message box.
0
 
LVL 5

Expert Comment

by:Emanon_Consulting
Comment Utility
I'll ask some others to have a look...

Cheers
M
0
 

Author Comment

by:JordanKingsley
Comment Utility
thanks M
0
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
First issue I see is the possibility that Me![UniqueID] is NULL.  Even if it should never be NULL, it's always a good idea to check for it.  Users are notoriously ingenious in finding ways to do things they "can't" do.  :)

' The -1 value is just arbitrary...you can make it whatever you want.
stLinkCriteria = "[UniqueID]=" & NZ(Me![UniqueID],-1)

I also agree with Emanon that you should remove the default value assignment from the [UniqueID] control on the Admissions form.  By setting the link criteria, you are effectively telling the Admissions form that no other [UniqueID] value should be available.

For troubleshooting, I suggest putting a breakpoint in the OnLoad event of the Admissions form, or in the OnClick event for the command button on the main form.  This way you can check the value of stLinkCriteria during execution to verify its validity.  Also, your code assumes that [UniqueID] is a numeric value.  Finally, please detail the title bar and text on the prompt you receive.  It will tell us what parameter it thinks it needs, and may provide a clue as to the source of the error.
0
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
DOH!  If you have any code in the OnLoad event of the Admissions form, please post that as well.
0
 

Author Comment

by:JordanKingsley
Comment Utility
Thanks for looking at this routinet. The UniqueID isn't null. The way this is filtered from Clients to Admissions there shouldn't be any other UniqueID available except the one showing on the Clients Form when the Admissions Form is opened. What you said about the code assuming that the UniqueID is a numeric may be the problem. The UniqueID is a generated field that is a text. It contains first letter of the last name and first letter of the first name. In the past I have used text fields in this manner but they've only contained numbers. An example of a UniqueID is "M04N61225". The exact prompt that I get (if that exact UniqueID was showing is):

 Enter Parameter Value (Blue part of msgbox)

 M04N61225 (Right above text box)

 
 When I click ok it's at that exact UniqueID anyway. You probably have a good idea of what I'm doing wrong now. Thanks
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:JordanKingsley
Comment Utility
PS there is no on load event for the Admissions form. The command button is the only source.
0
 
LVL 54

Expert Comment

by:nico5038
Comment Utility
I'm getting the impression that the error is in another control on the triggered form.
Did you try to open the form "stand alone" and do you get the message box then too ?

When it's a simple form just create a new one and try again, otherwise you'll have to dig into the combo's and other controls that are "data related" by using a query.

Nic;o)
0
 

Author Comment

by:JordanKingsley
Comment Utility
Hello Nic;0), the message doesn't come up when I open it by it'self. I'll do another form then. I think what routinet said about the code assuming it's a numeric could be the cause.
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
Comment Utility
stLinkCriteria = "[UniqueID] = '" & Me![UniqueID] & "'"

The only change is the addition of single quotes around Me![UniqueID].  The difference:

Originally:  stLinkCriteria = "[UniqueID] = M04N61225"
After:  stLinkCriteria = "[UniqueID] = 'M04N61225'"

The problem is that Access needs a text string for the parameter.  By not putting the single-quotes around your value, you imply that M04N61225 is a user-provided value to match, and Access in turn asks for it.
0
 

Author Comment

by:JordanKingsley
Comment Utility
Routinet? You totally RULE !!!! That was exactly it. Thank you so much !!!!!
0
 
LVL 5

Expert Comment

by:Emanon_Consulting
Comment Utility
Hey Folks

I just got out of my meeting...

>>JordanKingsley - Sorry to have started and then have to leave ya hanging.  Work gets in the way of my free time once in a while!

>> routinet - Thanks a bunch coming to help!

Cheers
Michael
0
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
I live to serve.  <smirk>
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now