I just started with VBA today teaching my self how to export data from a access form to a .txt file.
I have a form with a series of combo boxes and 2 tick boxes and I am trying to export the selections every time a change is made by clicking the command button. But when I click the button I get the following error;
"Run time error '2185' You can't reference a property or method for a control unless it has the focus".
I have no idea what this means. I am also including my code, I also want the data to add onto the data already contained in the .txt file and not over write it. I am not sure if my open file loop will do this.
Private Sub Command0_Click()
Dim boxWorksheets As String
Dim boxSites As String
Dim boxClinical As String
Dim boxTriage As String
Dim boxTriageOutput As String
Dim boxClinicalOutput As String
Dim boxClericalOutput As String
Dim checkWork As Boolean
Dim checkFree As Boolean
boxWorksheets = Combo12.Text
boxSites = Combo14.Text
boxClerical = Combo16.Text
boxClinical = Combo18.Text
boxTriage = Combo20.Text
checkWork = Check22.Boolean
checkFree = Check24.Boolean
boxTriageOutput = Combo38.Text
boxClinicalOutput = Combo40.Text
boxClericalOutput = Combo42.Text
Open "C:\Documents and Settings\chicks\Desktop\medical alert.txt" For Output As #1
Write #1, boxWorksheets, boxSites, boxClincial, boxTriage, boxTriageOuput, boxClinicalOutput, boxClericalOuput, checkWork, checkFree
Close #1
End Sub
Any help anyone can provide would be awesome.
I have a form with a series of combo boxes and 2 tick boxes and I am trying to export the selections every time a change is made by clicking the command button. But when I click the button I get the following error;
"Run time error '2185' You can't reference a property or method for a control unless it has the focus".
I have no idea what this means. I am also including my code, I also want the data to add onto the data already contained in the .txt file and not over write it. I am not sure if my open file loop will do this.
Private Sub Command0_Click()
Dim boxWorksheets As String
Dim boxSites As String
Dim boxClinical As String
Dim boxTriage As String
Dim boxTriageOutput As String
Dim boxClinicalOutput As String
Dim boxClericalOutput As String
Dim checkWork As Boolean
Dim checkFree As Boolean
boxWorksheets = Combo12.Text
boxSites = Combo14.Text
boxClerical = Combo16.Text
boxClinical = Combo18.Text
boxTriage = Combo20.Text
checkWork = Check22.Boolean
checkFree = Check24.Boolean
boxTriageOutput = Combo38.Text
boxClinicalOutput = Combo40.Text
boxClericalOutput = Combo42.Text
Open "C:\Documents and Settings\chicks\Desktop\medical alert.txt" For Output As #1
Write #1, boxWorksheets, boxSites, boxClincial, boxTriage, boxTriageOuput, boxClinicalOutput, boxClericalOuput, checkWork, checkFree
Close #1
End Sub
Any help anyone can provide would be awesome.