• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

OpenArgs, getting random errors.

I have been using the code below to open a form and then go to a patient's record. I am using the OpenArgs function so that after I open the form to the record that I initially chose, I can then navigate to other records without having to close the form first.

'Patient name double click opens PhysicianRecordForm
Private Sub PatientName_DblClick(Cancel As Integer)
DoCmd.RunCommand acCmdSaveRecord
Dim strFormName As String
Dim strCriteria As String
strFormName = "PhysicianRecordForm"
strCriteria = "[MRN]= " & Me![MRN]
DoCmd.OpenForm strFormName, OpenArgs:=strCriteria
End Sub

Open in new window


This has worked well up until the past few weeks when two of my users started getting error messages "record not found". I am getting the error on only about half of the patients, the other half still works well. Decompile and recompile does not help.  I think that it is a glitch with the OpenArgs function. Should I be using the TempVars method instead?  Any ideas?
0
Drjdh
Asked:
Drjdh
  • 12
  • 10
1 Solution
 
IrogSintaCommented:
There should be no problem using the OpenArgs parameter.  Is [MRN] a Number data type? Or is it really a String data type?  If the latter then your strCriteria should be:
strCriteria = "[MRN]= '" & Me.[MRN] & "'"

Open in new window

If the above is fine, then you should try to narrow your problem down a bit.  Can you consistently produce the error for a certain patient?  If so, put a breakpoint somewhere in your form PhysicianRecordForm and see if OpenArgs has the correct MRN.
0
 
Rey Obrero (Capricorn1)Commented:
if you are using the open event of the form "PhysicianRecordForm" to get the openArgs value and getting the errors,

  use the "LOAD" event of the form.
0
 
DrjdhAuthor Commented:
Thanks IrogSinta, MRN is a number.

The interesting thing is that this line of code has worked well for the past 6 months or so. It is only in the past few weeks that 2 users have begun to have the problem. The problem is only with their copy of the database, and only with a few patients (records) in this database.

To me, this points to something corrupted. If I can't fix the problem, then I will have to reinvent the code as I can't have users crashing in the middle of the night!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DrjdhAuthor Commented:
Capricorn1, thanks for your help with this. You actually developed this code for me in a previous post *Thanks!*.  Regarding your question, here is the Load Event of the form that gets opened:

Private Sub Form_Load()
If Me.OpenArgs & "" <> "" Then
With Me.RecordsetClone
   .FindFirst Me.OpenArgs
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    Else
    MsgBox "record not found"
    End If
End With
End If
End Sub

Open in new window

0
 
Rey Obrero (Capricorn1)Commented:
are you using a FE-BE setup? is the back end an access db or not?
this could be a timing problem.
did you trace the operation they did when they got the error?
0
 
DrjdhAuthor Commented:
The database is not split.  It is run locally on a PC. One interesting point is that the two individuals who have had this problem are both running the Access file from a server location instead of the desktop.
0
 
Rey Obrero (Capricorn1)Commented:
i think it is about time that you split your db..
0
 
DrjdhAuthor Commented:
I know, I just don't have access to server space right now.
0
 
DrjdhAuthor Commented:
I spoke with the end-users that were involved in the cases and they seem to think that the error appeared after they clicked on a blank record.

Would the code be more robust if I revised it using the TempVars method instead?
0
 
Rey Obrero (Capricorn1)Commented:
<they seem to think that the error appeared after they clicked on a blank record.>

well, i don't consider that as an error
the message is just informing them that the record does not exists..

Private Sub Form_Load()
If Me.OpenArgs & "" <> "" Then
With Me.RecordsetClone
   .FindFirst Me.OpenArgs
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    Else
   MsgBox "record not found"   '<<< THIS is where the message is coming from
    End If
End With
End If
End Sub
                                           




TempVars will just behave the same.
0
 
DrjdhAuthor Commented:
I guess that I was not clear; I understand that you will get an error message if the record does not exist.  They portend that by accidentally clicking a blank record, they somehow changed something in the database that is irreversible. The error that I am getting is on records that clearly exist; both in the tables and the queries that are associated with the form.
0
 
Rey Obrero (Capricorn1)Commented:
<The error that I am getting is on records that clearly exist; both in the tables and the queries that are associated with the form.>

ok, try this codes.
this will display in a msgbox the OpenArgs value that was passed to the form


Private Sub Form_Load()
If Me.OpenArgs & "" <> "" Then

msgbox me.openargs

With Me.RecordsetClone
   .FindFirst Me.OpenArgs
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    Else
   MsgBox "record not found"  
    End If
End With
End If
End Sub
0
 
DrjdhAuthor Commented:
Thanks for the code Capricorn. I've been out of town.

On the records that are working the msg gives the MRN (key), then opens the form to that record. On the records that are NOT working, the msg gives the MRN, then "record not found" text.
0
 
Rey Obrero (Capricorn1)Commented:
that is what the codes must do.

if the record based on the MRN is not found, then the record is not there.
0
 
DrjdhAuthor Commented:
But the record is in the table. Interesting.
0
 
Rey Obrero (Capricorn1)Commented:
upload a copy of the db..  
and give explanation how to recreate the problem..
0
 
DrjdhAuthor Commented:
The database is too large to copy over (160mb without data). Is there a way to reset the OpenArgs? perhaps this is the problem.
0
 
Rey Obrero (Capricorn1)Commented:
<The database is too large to copy over (160mb without data).>

you don't need to upload the whole thing..
create a copy of the db, delete all the objects that is not part of this problem..
zipped the file and upload.
just make sure there are sample data available for testing.


<Is there a way to reset the OpenArgs? perhaps this is the problem. >
what exactly do you mean?
0
 
DrjdhAuthor Commented:
My thought is that the error was introduced as timing: OpenArgs sets a parameter in form 1 then form 2 uses the value in OpenArgs to find the record. Perhaps the value in OpenArgs has been locked (or something to that effect).
0
 
Rey Obrero (Capricorn1)Commented:
<Perhaps the value in OpenArgs has been locked (or something to that effect).>

i couldn't imagine how it could happen..
that is why i need your sample db and the steps to reproduce the error.
0
 
DrjdhAuthor Commented:
Here is a copy of the database.  Double click on the patient name to open form 2.
Dysfunctional-DB.accdb
0
 
Rey Obrero (Capricorn1)Commented:
your form "PhysicianRecordForm" was saved with a value in the FIlter property

x
remove it and save the form..

see this revised db

i also enabled the record navigation in the form so  you can see how many records are available in the form.
functional-DB.accdb
0
 
DrjdhAuthor Commented:
Thanks Capricorn!!  Great work.  

I don't know why I keep getting values in the filter property of my forms.  I have had a similar issue with the other form (Form1) causing records to be listed out of order. Is there a setting that I can change to prevent this in the future?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 12
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now