Hello
I've got so very close to getting this working and I've spent god knows how many days looking through the internet trying to find the solution to my problem.
I'm hoping that I can gain some help from here.
I have 2 Tables:
XrayData
XrayDataOriginalCD
How my database works:
A record is created in XrayData, this holds simple information like a reference number and full name.
We obtain records on disc from hospitals which we need to record when received. This is done in XrayDataOriginalCD. This is because 1 case might have 10 CD's related to it.
Both tables have a CaseNumber field.
I have created a querysubform which looks at the XrayDataOriginalCD table and is present on the XrayData main form.
My Goal:
To export into XML format the data from the XrayDataOriginalCDQuerySubform but where the CaseNumber field Matches and doesn't include any other cases. So what ever record I am viewing in XrayData is exported from the XrayDataOriginalCD.
I do have the export working sort of, but this seems to export all cases, and I can no longer see where I am going wrong.
I'm extremely new to VBA and have managed to pick snippets up from other sources to get this far. Just need this last bit of the puzzle slotting in.
Here is the code:
I think the problem maybe with the 'Application.ExportXML' line.
Any help would be greatly appreciated.
Finche
I've got so very close to getting this working and I've spent god knows how many days looking through the internet trying to find the solution to my problem.
I'm hoping that I can gain some help from here.
I have 2 Tables:
XrayData
XrayDataOriginalCD
How my database works:
A record is created in XrayData, this holds simple information like a reference number and full name.
We obtain records on disc from hospitals which we need to record when received. This is done in XrayDataOriginalCD. This is because 1 case might have 10 CD's related to it.
Both tables have a CaseNumber field.
I have created a querysubform which looks at the XrayDataOriginalCD table and is present on the XrayData main form.
My Goal:
To export into XML format the data from the XrayDataOriginalCDQuerySubform but where the CaseNumber field Matches and doesn't include any other cases. So what ever record I am viewing in XrayData is exported from the XrayDataOriginalCD.
I do have the export working sort of, but this seems to export all cases, and I can no longer see where I am going wrong.
I'm extremely new to VBA and have managed to pick snippets up from other sources to get this far. Just need this last bit of the puzzle slotting in.
Here is the code:
Code:
Private Sub ExportRecord_Click()
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim strSQL As String
Dim selID As String
Dim CurrRec As Integer
'Used to create a Recordset of Record IDs for Form Filtering for each
'Record. [ID] is the Primary Key making the job easy
strSQL = "Select XrayData.[CaseNumber] From XrayData;"
selID = Forms!XrayRegisterRecordsForm!CaseNumber
CurrRec = Me!XrayDataOriginalCDQuerySubform.Form.CurrentRecord
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenSnapshot)
With MyRS
Me!XrayDataOriginalCDQuerySubform.Form.RecordSource = "Select * From XrayDataOriginalCD Where [CaseNumber] = " & """ & selID & """
Application.ExportXML acExportQuery, "XrayDataOriginalCDQuery", "file path here" & [CaseNumber] & ".xml"
End With
Me.RecordSource = "Select * From XrayData Where [ID] = [ID]"
DoCmd.GoToRecord acDataForm, "XrayRegisterRecordsForm", acGoTo, XrayCurrRec
DoCmd.GoToRecord acDataForm, "XrayRegisterRecordsForm", acGoTo, CurrRec
MyRS.Close
Set MyRS = Nothing
End Sub
I think the problem maybe with the 'Application.ExportXML' line.
Any help would be greatly appreciated.
Finche