Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus Error

Status
Not open for further replies.

Ringers

Technical User
Feb 26, 2004
180
AU
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.
 
try this

Dim checkWork
Dim checkFree

checkWork = Check22.value
checkFree = Check24.value

also you may need to change "output" to "append"

ck1999
 
I change the .text to value, but now it is saying object required for checkWork22?
 
It is now working with Value, but this is returning the position of the check box string ('1' or '3' etc) from the table not the actual string. Which is what i need.
 
why not use an if statement
if checkbox33.value = 1 then
checkwork1= true
else
checkwork1=false
end if

it that still does not do it use "true" and "false"

ck1999
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top