I had finally gotten it working and it was attributed to the rs.openrecordset line.
Now I have the same issue again and that won't fix it. On top of that, I went back to just to see what would happen and removed rs.openrecordset from my other program and it still works! Could someone please help me figure out what I'm doing wrong...could it be something to do with my query? I am calling a different query from the new program so that's all I can think of.
Thanks in advance!
This is the query that works
Private Sub Output_With_Ins_File()
Dim rsQuery As Recordset
Set rsQuery = CurrentDb.OpenRecordset("LYTEC_Insert_Ins_To_Demo")
LCount = 0
LDone = 0
rsQuery.MoveFirst
Do Until rsQuery.EOF
LCount = LCount + 1
rsQuery.MoveNext
Loop
'LCount = rsQuery.RecordCount
DoEvents
Form_Progress.Label2.Caption = "Converting Demos"
Form_Progress.Label6.Caption = "Demos Converted"
DoEvents
'rsQuery.OpenRecordset
Open DemoOPFile For Output As #52
rsQuery.MoveFirst
Do Until rsQuery.EOF
Demo.MRN = rsQuery.Fields("MRN") & ""
Demo.SSN = rsQuery.Fields("SSN") & ""
Demo.FName = rsQuery.Fields("FName") & ""
Demo.MName = rsQuery.Fields("MName") & ""
Demo.LName = rsQuery.Fields("LName") & ""
Demo.DOB = rsQuery.Fields("DOB") & ""
Demo.Sex = rsQuery.Fields("Sex") & ""
Demo.Email = rsQuery.Fields("Email") & ""
Demo.Addy1 = rsQuery.Fields("Add1") & ""
Demo.Addy2 = rsQuery.Fields("Add2") & ""
Demo.City = rsQuery.Fields("City") & ""
Demo.State = rsQuery.Fields("State") & ""
Demo.Zip = rsQuery.Fields("Zip") & ""
Demo.Country = rsQuery.Fields("Country") & ""
Demo.Phone = rsQuery.Fields("HomePhone") & ""
Demo.GuarMRN = rsQuery.Fields("GuarMRN") & ""
Demo.GuarRela = rsQuery.Fields("GuarRel") & ""
Demo.EmpName = rsQuery.Fields("EmpName") & ""
Demo.EmpAddy1 = rsQuery.Fields("EmpAdd1") & ""
Demo.EmpAddy2 = rsQuery.Fields("EmpAdd2") & ""
Demo.EmpCity = rsQuery.Fields("EmpCity") & ""
Demo.EmpState = rsQuery.Fields("EmpState") & ""
Demo.EmpZip = rsQuery.Fields("EmpZip") & ""
Demo.EmpCountry = rsQuery.Fields("EmpCountry") & ""
Demo.EmpPhone = rsQuery.Fields("EmpPhone") & ""
Demo.EmpExt = rsQuery.Fields("EmpExt") & ""
Demo.MarStat = rsQuery.Fields("MarStat") & ""
Demo.GPro = rsQuery.Fields("GPro") & ""
Demo.GProNPI = rsQuery.Fields("GNPI") & ""
Demo.PatNotes = rsQuery.Fields("Notes") & ""
Demo.PatGroup = rsQuery.Fields("Group") & ""
Demo.Ins1ID = rsQuery.Fields("Ins1ID") & ""
Demo.Ins1Name = rsQuery.Fields("LytecInsInfo.InsCo") & ""
Demo.Ins1Addy = rsQuery.Fields("Expr1") & ""
Demo.Ins1PolNum = rsQuery.Fields("Ins1Pol") & ""
Demo.Ins1CoPay = rsQuery.Fields("Ins1CP") & ""
Demo.Ins1GroupNum = rsQuery.Fields("Ins1Group") & ""
Demo.Ins1SubMRN = rsQuery.Fields("Ins1SubMRN") & ""
Demo.Ins1SubRela = rsQuery.Fields("Ins1SubRel") & ""
Demo.Ins2ID = rsQuery.Fields("Ins2ID") & ""
Demo.Ins2Name = rsQuery.Fields("LytecInsInfo_1.InsCo") & ""
Demo.Ins2Addy = rsQuery.Fields("Expr2") & ""
Demo.Ins2PolNum = rsQuery.Fields("Ins2Pol") & ""
Demo.Ins2CoPay = rsQuery.Fields("Ins2CP") & ""
Demo.Ins2GroupNum = rsQuery.Fields("Ins2Group") & ""
Demo.Ins2SubMRN = rsQuery.Fields("Ins2SubMRN") & ""
Demo.Ins2SubRela = rsQuery.Fields("Ins2SubRel") & ""
Demo.Ins3ID = rsQuery.Fields("Ins3ID") & ""
Demo.Ins3Name = rsQuery.Fields("LytecInsInfo_2.InsCo") & ""
Demo.Ins3Addy = rsQuery.Fields("Expr3") & ""
Demo.Ins3PolNum = rsQuery.Fields("Ins3Pol") & ""
Demo.Ins3CoPay = rsQuery.Fields("Ins3CP") & ""
Demo.Ins3GroupNum = rsQuery.Fields("Ins3Group") & ""
Demo.Ins3SubMRN = rsQuery.Fields("Ins3SubMRN") & ""
Demo.Ins3SubRela = rsQuery.Fields("Ins3SubRel") & ""
Demo.GenData = rsQuery.Fields("GenData") & ""
Demo.RefPro = rsQuery.Fields("RPro") & ""
Demo.RefProNPI = rsQuery.Fields("RNPI") & ""
Demo.RefProNPI = rsQuery.Fields("RNPI") & ""
Demo.Diag1Code = rsQuery.Fields("Diag1Code") & ""
Demo.Diag1Date = rsQuery.Fields("Diag1Date") & ""
Demo.Diag1Note = rsQuery.Fields("Diag1Notes") & ""
Demo.Diag2Code = rsQuery.Fields("Diag2Code") & ""
Demo.Diag2Date = rsQuery.Fields("Diag2Date") & ""
Demo.Diag2Note = rsQuery.Fields("Diag2Notes") & ""
Demo.Diag3Code = rsQuery.Fields("Diag3Code") & ""
Demo.Diag3Date = rsQuery.Fields("Diag3Date") & ""
Demo.Diag3Note = rsQuery.Fields("Diag3Notes") & ""
OPRec = Demo.FormatOPRecord
Print #52, OPRec
OPRec = Demo.ClearValues
DoEvents
LDone = LDone + 1
Form_Progress.AXC.Value = (LDone / LCount) * 100
Form_Progress.Label5.Caption = LDone
DoEvents
ReRun:
rsQuery.MoveNext
Loop
Close #52
End Sub
This is the one that doesn't work
Sub InsertMRNtoAppt()
'Select the appt file first then select the file with chart numbers
Dim rsCache As Recordset
Dim ApptFile As String
Dim MRNFile As String
Dim rsQuery As Recordset
Dim ProName As String
Dim Appt
ProName = InputBox("Enter Provider Name", "Pro Name", "Enter here!!!")
If ProName = "" Then
End
Me.Visible = True
End If
Set rsCache = CurrentDb.OpenRecordset("File_Cache")
Set rsQuery = CurrentDb.OpenRecordset("CT_Insert_MRN_To_Appt_Extract")
Set Appt = New CT_Appt_Data
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * from CT_Appt_Extract"
DoCmd.RunSQL "DELETE * from CT_MRN_Extract"
DoCmd.SetWarnings True
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Select Input Files %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MsgBox "Select Appointment Extract", vbExclamation, "Appts"
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
If .Show = False Then End
.Title = "Appointment Extract"
ApptFile = .SelectedItems(1)
End With
Do Until IntLastSlash = 0
IntLastSlash = InStr((IntLastSlash + 1), ApptFile, "\")
If IntLastSlash <> 0 Then
IntSlashHold = IntLastSlash
End If
Loop
MsgBox "Select Chart Number Extract", vbExclamation, "MRN Extract"
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
If .Show = False Then End
.Title = "Chart Number Extract"
MRNFile = .SelectedItems(1)
End With
IntLastSlash = InStr(1, ApptFile, "\")
Do Until IntLastSlash = 0
IntLastSlash = InStr((IntLastSlash + 1), MRNFile, "\")
If IntLastSlash <> 0 Then
IntSlashHold = IntLastSlash
End If
Loop
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' remember the selected directory for subsequent dialog boxes...
InitDir = Mid(ApptFile, 1, (IntSlashHold - 1))
InputFile = Mid(ApptFile, (IntSlashHold + 1))
OPFile = InitDir & "\" & ProName & "_CtReady.csv"
DoCmd.TransferText acImportDelim, "MainApptSpec", "CT_Appt_Extract", ApptFile, False
DoCmd.TransferText acImportDelim, "MRNExtractSpec", "CT_MRN_Extract", MRNFile, False
Form_Progress.Visible = True
rsQuery.MoveFirst
Do Until rsQuery.EOF
LCount = LCount + 1
rsQuery.MoveNext
Loop
'rsQuery.OpenRecordset
Open OPFile For Output As #53
'OPRec = Appt.ClearValues 'Just as an added precaution to save headaches
rsQuery.MoveFirst
Do Until rsQuery.EOF
Appt.aDate = rsQuery.Fields("Date") & ""
Appt.aTime = rsQuery.Fields("Time") & ""
Appt.aDuration = rsQuery.Fields("Duration") & ""
Appt.aLoc = rsQuery.Fields("Loc") & ""
Appt.aLocID = rsQuery.Fields("LocID") & ""
Appt.aType = rsQuery.Fields("Type") & ""
Appt.aTypeID = rsQuery.Fields("TypeID") & ""
Appt.aPro = rsQuery.Fields("Pro") & ""
Appt.aProID = rsQuery.Fields("ProID") & ""
Appt.aGroupID = rsQuery.Fields("GroupID") & ""
Appt.aGroup = rsQuery.Fields("Group") & ""
Appt.aMRN = rsQuery.Fields("MRN") & ""
Appt.ANotes = rsQuery.Fields("Notes") & ""
Appt.aComplaint = rsQuery.Fields("Complaint") & ""
Appt.aFName = rsQuery.Fields("FName") & ""
Appt.aMName = rsQuery.Fields("MName") & ""
Appt.aLName = rsQuery.Fields("LName") & ""
Appt.aDOB = rsQuery.Fields("DOB") & ""
Appt.aSex = rsQuery.Fields("Sex") & ""
OPRec = Appt.FormatOPRecord
Print #53, OPRec
OPRec = Appt.ClearValues
LDone = LDone + 1
DoEvents
Form_Progress.AXC.Value = (LDone / LCount) * 100
Form_Progress.Label5.Caption = LDone
DoEvents
rsQuery.MoveNext
Loop
Close #53
End Sub

New Topic/Question
Reply




MultiQuote





|