Full Version: Problem with form/subform and SQL
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
tor
I ran in to a problem with my db. It seem's my brain's still on holiday...
I have a form with order information and a subform with document information(filename).
One order have several documents. When I click a button on the mainform I want to make the files in the subform readonly (attribute).
I have the readonly part figured out. But when i click the button I only changes the first record in the subform.
I know the solution for this is simple, but my brain got wery complicated just now.....

I have attached a sample database.
Chaga
You could always create a recordset and loop in it, for ex:


Private Sub btn_Click()
Dim fPath, fName, fComplete As String
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("select * from tblsub where tblMainID = " & Me.id)
fPath = "c:\test\"
While Not rs.EOF
fName = rs.Fields(1)
fComplete = fPath + fName
SetAttr (fComplete), vbReadOnly
rs.MoveNext
Wend
rs.Close
Set rs = Nothing

End Sub


But you will need to create some validation to check that the file exists before changing it's attribute, or else you'll get an error.
P.S:You will need to add the DAO 3.6 reference.

HTH
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.