Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2003 Code:  Open Arg help

Posted on 2009-07-10
9
Medium Priority
?
269 Views
Last Modified: 2013-11-28
The code I have below is currently working, but I need to add some items to it but i'm not sure how to do the iloc:

I need to add:

            Antibiotic = Left$(Me.OpenArgs, iLoc - 1)
            Frequency = Left$(Me.OpenArgs, iLoc - 1)
            DateOrdered = Left$(Me.OpenArgs, iLoc - 1)
            TimeOrdered = Left$(Me.OpenArgs, iLoc - 1)
So I used the code from PatientName (  = Left$(Me.OpenArgs, iLoc - 1) ) and now all my text boxes contain patient name.  I'm not sure  how to change this line of code to pull the other data in.

Thanks in Advance!
       
Private Sub Form_Open(Cancel As Integer)
    ' Must pass it PatientName and MRN as arguments
 
    AskToUnload = False
    If Nz(Me.OpenArgs, "") = "" Then
        MsgBox "Error: No Patient Information Supplied", vbCritical + vbOKOnly, "No Patient Info"
        Cancel = True
    Else
        Dim varData As Variant
        Dim iLoc As Integer
        iLoc = InStr(Me.OpenArgs, ",")
        If iLoc > 0 Then
            PatientName = Left$(Me.OpenArgs, iLoc - 1)
            txtFIN = Mid(Me.OpenArgs, iLoc + 1)
            Else
            MsgBox "Error: Invalid Patient Information Supplied", vbCritical + vbOKOnly, "Invalid Patient Info"
            Cancel = True
        End If
    End If
End Sub

Open in new window

0
Comment
Question by:Namrac00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
Berkson Wein earned 1600 total points
ID: 24828820
InStr is only going to return the location of the first comma in the OpenArgs string.
If you want to use OpenArgs to pass multiple values to the form, I'd use split to split the comma separated string into an array.  Here's an example using a zero based array.   This assumes that you're sending the array starting with the patient name, then MRN, then the others in the order that you have listed above.  Make sure there are no commas in the data.  Maybe separate with something like | which is less likely to appear in the data.
Hope this helps.


    Dim arrayOpenArgs As Variant
    ' this splits the string into the separate array variables
    arrayOpenArgs = Split(Me.OpenArgs, ",", -1)
 
    PatientName = arrayOpenArgs(0)
    txtFIN = arrayOpenArgs(1)
    Antibiotic = arrayOpenArgs(2)
    Frequency = arrayOpenArgs(3)
    DateOrdered = arrayOpenArgs(4)
    TimeOrdered = arrayOpenArgs(5)

Open in new window

0
 

Author Comment

by:Namrac00
ID: 24828833
I get a subscript out of range error on the Antibiotic
0
 
LVL 85
ID: 24828889
OpenArgs is a String value you can pass into a form or report.

Can you tell us what is being passed into the form? According to your code, you're passing in the PatientName and MRN ... if you also wish to pass in the Antiboiotics, Frequency, etc, then you'd have to do that in the function that CALLS your form.

I have to question the wisdom of passing in information like this ... what's the need for passing in this many bits of information?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Namrac00
ID: 24828941
Well on the particular database.  You can choose to add multiple doses per FIN.  This allows you to view the FIN/antibiotic... that you are adding a dose to without having to fill out the information each time.

I will upload this b/c there is no real data in it.  You will click on:

Data Entry > MRN (drop down has a test number choose it) > find > double click on doses and you will see the areas that I am trying to bring over.

One of my issues is that the items I want to bring over:  antibiotic, frequency, dateordered, timeordered
can I connect these relationally to the table patientadmissions?  I want to make sure you don't have to repeat this data if you are just added a dose b/c you can give 100 doses of the same antibiotic if the patient is in the hospital for a long period of time.

Right now I have the two tables linked by the FIN, but they can have a different antibiotic with the same FIN so I need to make sure that it can do primarys on FIN/Antibiotic/DateOrder to cascade changes.
db12.zip
0
 
LVL 15

Assisted Solution

by:Berkson Wein
Berkson Wein earned 1600 total points
ID: 24828972
On the sfmPatientAdmissions subform, the event handler for double click of the dose field that sets the OpenArgs field is currently:
strOpenArgs = frm!FirstName & " " & frm!LastName & "," & FIN
 You're going to want to change that to something like:
strOpenArgs = frm!FirstName & " " & frm!LastName & "," & FIN & "," & Antibiotic & "," & Frequency & "," & DateOrdered & "," & TimeOrdered
 
 
0
 

Author Comment

by:Namrac00
ID: 24829010
alright I put in those changes now I get an error  (field is to small to except data) here:

 Private Sub Form_Load()
   
    If Me.NewRecord Then
        FIN = txtFIN
       
        strSQL = "SELECT NextDoseNumber FROM qGetNextDoseNumber WHERE FIN = '" & FIN & "'"
        Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
        If rs.EOF Then
            Me![Dose Number] = 1
        Else
            Me![Dose Number] = rs!NextDoseNumber
        End If
    End If
    End Sub

--------------------

because where it is saying FIN = txtFIN it is putting all the string of FIN, antibiotic, frequency...

0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 total points
ID: 24829933
Since you state a patient can have more than one antibiotic during their stay, you'll need some table changes to make this work effectively. I'm assuming an Antibiotic is some form of drug or treatment; if so, you'd need a table to store those (since, presumably, more than one Patient will be given this Antibiotic) and a table to store the when those antibiotics are given to a specific patient:

tblAntibiotics
--------------------
lAntiBioticID
sABName
etc etc

Your [Dose Encounters] table could be used as the Join between this table and the tblPatientAdmissions table. You'd need to store the lAntibioticID value in the [Dose Encounters] table.

Also, I don't see where you need the Antibiotic or Frequency in your tblPatientAdmissions ... from a data standpoint, those don't belong in that table (at least to my understanding of what you're doing).

From there, you can build a query that returns the Dose info + Patient info ... and there'd be no need for the OpenArgs business to pass in the data you need.

0
 

Author Comment

by:Namrac00
ID: 24830487
If they don't enter it in the patient Admissions then they would have to enter in the general antibiotlic information in each dose?
0
 
LVL 85
ID: 24831213
No ... I'd assume that Patient data would be entered in a Patient table, and you'd use that table when you build "joins" with the Antibiotics table. IMO, OpenArgs is most definitely not the thing to use with this ...
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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