automated click

johnlatona123

Innovator
Local time
Yesterday, 18:10
Joined
Sep 20, 2011
Messages
85
hi all,

i was hoping someone can help me with an issue.

i have a form, that now has 2 checkboxes.

one checkbox, when clicked, opens a file on my server based on some criteria
---------------------------------------------------------------------------
Private Sub Page1_Click()
On Error GoTo Err_Page1_Click
Dim response, mystring
mystring = "CAN'T FIND THE DRAWING!"
Dim strInput As String
strInput = "N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg"
Application.FollowHyperlink strInput, , True
[Page1] = 0
Exit_Page1_Click:
Exit Sub

Err_Page1_Click:
response = MsgBox(mystring, vbOKOnly)
[Page1] = 0
Resume Exit_Page1_Click
End Sub

------------------------------------------------------------------------------------
the other checkbox, is the problem. i want this checkbox to run a check for the file on the server and if it exists, this check box would be checked when the form loads or opens.

i then need to create a button that can "click" a group of check boxes and run thier functions all at once.

any ideas?

please advise.
 
It sounds like you need to check for existence of the file in the forms open event and if the file exists, you want a checkbox to be checked and a button to be made visible?

The button click event would just need to call each event of your other checkboxes
Call checkbox2_Onclick()
call checkbox3_onclick()
 
yes you are correct, i want to know if the file or files exist when the form opens.
 
i tried this
The button click event would just need to call each event of your other checkboxes
Call checkbox2_Onclick()
call checkbox3_onclick()

and the result is an error

maybe it would be helpful for you to know that this is a continuous form and the same check box exists for multiple records
 
aha...I see. Is the checkbox unbound??

Also, what's the error you get?
 
it is now bound to a field, similar to the working one.

maybe the easier solution is to write a on open verification of that file path?

please advise
 
so not sure how to write it, but my thought is to write something like:

when the form opens

validate file path for each record in the continuous form, if file paths are good, check the box for each record that is good, if file paths are bad(no file found), then dont check the box for each record

can you help me write that?
 
when you open the main form do you need to validate ALL records? Or do you need to only validate one at a time? If that is the case you should put your code in the onCurrent event of the record. The code will run only when user selects that record.
 
Here is what you need to check if file exists:
Code:
If Len(Dir(yourfilepath)) > 0 Then
        'file exists
 End If
 
access 2010.

when the form opens, all records need to be validated before the form loads.

the structure is that there is one main record in this example that has multiple sub-records
 
can you rephrase that stamemnt using this?

"N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg"
 
Dim yourfilePath as string
yourfilePath = "N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg"

If Len(Dir(yourfilepath)) > 0 Then
'file exists
End If
 
Are you using a main form and then your continuous form records are in your subform?
 
Are you using a main form and then your continuous form records are in your subform?

yes.

so i tried this on open/load:

Private Sub Form_Load()
Dim yourfilePath As String
yourfilePath = "N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg"
If Len(Dir("N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg")) > 0 Then [Verify] = -1

End Sub

and as i debug it, it seems it is pulling in the correct values for the file path, but it is not toggleing the [verify] checkbox.
 
Is the verify button on your subform or main form?

Try Verify = true
 
the [verify] item is a check box on the subform (1 for each record)

cant quite get it working, any more ideas?
 
ive been putting the code on open on the main form, does it need to be on the subform?
 
It's not going to work the way you are trying to do it. The code will only run for the current record in the form. The only way you will be able to do it in the subform is by looping through every record in the subform in VBA and checking. Sorry, I know I asked this previously, but the VERIFY checkbox is a bound field, correct? Does the same file path apply to every record or do you need to confirm a different filepath for each subform record?
 
im willing to do whatever method will work, and i appreciate you helping me through this.

ok, the looping thing makese sense, the verify check box is currently bound to make it record specific, however no data is stored in it ( all records have this false) for the sake of the verification process.

the file path is different every time

i was messing around with this idea, which isnt working either

Private Sub Form_Load()
Dim yourfilePath As String
yourfilePath = "N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg"
If Len(Dir("N:\DRAWINGS\" & [Drawing#] & "-01_" & [DwgRev] & ".dwg")) > 0 Then
[Verify] = 1
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom