UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Problem with form/subform and SQL    
 
   
tor
post Nov 22 2004, 07:35 PM
Post #1

New Member
Posts: 12
From: Norway



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.
Go to the top of the page
 
+
Chaga
post Nov 23 2004, 02:22 AM
Post #2

UtterAccess VIP
Posts: 2,579
From: Abu Dhabi, U.A.E



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
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 01:39 AM