We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Access 2003 Code:  Open Arg help

Namrac00
Namrac00 asked
on
Medium Priority
289 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

Comment
Watch Question

Tech Freelancer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
I get a subscript out of range error on the Antibiotic
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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?

Author

Commented:
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
Berkson WeinTech Freelancer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
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...

Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
If they don't enter it in the patient Admissions then they would have to enter in the general antibiotlic information in each dose?
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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 ...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.