Results 1 to 6 of 6
  1. #1
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143

    Enter Parameter Value error handling


    I've got a button to run a query that requires a parameter value (4-digit retail product number). If there is an error (someone enters a wrong number that doesn't exist), I have it set to open a message saying "Please enter a valid number".
    The problem is that this message comes up for every error. Right now the most common error is that someone presses the button and then decides that they didn't want to run the query and so just closes the parameter value window.
    Is there a way to differentiate between these? Or cancel the event if the parameter window is closed?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    use a form. On the form put a combo box with all existing prod#s.
    and a button to execute.
    The query looks at this as the param.
    (i.e.: select * from table where [prod]=forms!myForm!cboProdNum)

    1, they cannot pick a wrong product
    2. they can click / or not click the button to open the query

  3. #3
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    I'm having a bit of trouble with the query.
    So the main problem is that there are copies of the exact same button, one on a form and two on reports. This is what I have so far, but nothing is being returned:
    Code:
    SELECT Right([RetailNum],4) AS Retail, [tblOrderDetails].ConfNum
    FROM [tblOrderDetails]
    WHERE ((([tblOrderDetails].ConfNum)=GetValue()));
    The Get Value which I use throughout the database function is as follows:
    Code:
    Public Function GetValue()
        If CurrentProject.AllForms("frmOrderConf").IsLoaded = True Then
            GetValue = Forms![frmOrderConf]![ConfNum]
        ElseIf CurrentProject.AllForms("frmOrderList").IsLoaded = True Then
                GetValue = Forms![frmOrderList]![ConfNum]
        ElseIf CurrentProject.AllReports("rptSampleOrderConf").IsLoaded = True Then
                GetValue = Reports![rptSampleOrderConf]![ConfNum]
        ElseIf CurrentProject.AllReports("rptOrderConfPS1").IsLoaded = True Then
                GetValue = Reports![rptOrderConfPS1]![ConfNum]
        Else
            GetValue = InputBox("Enter Confirmation Number")
        End If
    
    
    End Function
    The button is currently on "rptOrderConfPS1", "rptSampleOrderConf", and "frmOrderConf". I'm testing it out with "rptOrderConfPS1" and the list comes up empty even though there should be a list of 15 or so.

  4. #4
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    If I take out the GetValue criteria, I get a long list with all possible retail numbers and the ConfNum they're associated with. If I copy and paste a ConfNum from the query results list and put it in the criteria for ConfNum, the list comes up empty...

  5. #5
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    Oh, nevermind. The ConfNum is calculated off of the table primary key autonumber, so I just used getvalue() and reversed the calculation so that it would equal the primary key value. Not sure why this worked since I'm not using the primary key in the query.

  6. #6
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    Okay, whole new form works perfectly.
    Just what I needed!
    Thanks for the idea!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Enter Parameter Value Error
    By wojosh6 in forum Access
    Replies: 2
    Last Post: 12-15-2015, 09:56 AM
  2. Report 'Enter Parameter Value' Error
    By ndehhh in forum Programming
    Replies: 6
    Last Post: 10-18-2015, 05:18 PM
  3. Enter Parameter Value error
    By bronson_mech in forum Queries
    Replies: 9
    Last Post: 11-30-2013, 05:00 PM
  4. Enter Parameter Value Error in Macro
    By kasimagj in forum Programming
    Replies: 3
    Last Post: 09-19-2011, 03:53 PM
  5. Replies: 2
    Last Post: 04-18-2011, 06:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums