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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto selecting all all yes/no fields

Status
Not open for further replies.

TheEnigma

Technical User
May 26, 2002
69
US
Hello.

I have a form with a subform in it, that displays a record set in datasheet view, which comes from a query. In the record set it shows 3 different types of letters sent to customers. The letter field is a yes/no field. What I would like to do is create 3 buttons on the main form that upon clicking a button, selects all of the yes no fields for that corresponding button. E.g. Button 1, selects all Letter1, button 2, selects all Letter2.

The form name is LetterSent_frm, the subform is called LetterSent_sf. Each yes/no field is named Letter1, Letter2, Letter3.

Can anyone help please?

 
Hi!

I think Looping thru the subforms recordset might achieve this, something like this in each buttons on click event (substitute names):

[tt]dim rs as dao.recordset
set rs=me!YourSubFormName.Form.recordsetclone
if not rs .bof then
rs.movefirst
do while not rs.eof
rs.edit
rs!YourBooleanFieldName=True
rs.update
rs.movenext
loop
end if
set rs=nothing[/tt]

Substitute the subformname and field name, and it'll probably work. Note - If you're using access 2000+ version, and don't have a reference to the Microsoft DAO 3.# Object Library, you'd need to set it (in any module Tools | References)

HTH Roy-Vidar
 
Thanks for that, I did need to insert the reference to the DAO3 object library.

When I run this nwo though, I get an error coming up (Compile error: syntax error) and it highlights this line:

if not rs .bof then

The full code I put in on the button is:

Private Sub Command4_Click()
Dim rs As DAO.Recordset
Set rs = Me!LetterSent_sf.Form.RecordsetClone
if not rs .bof then
rs.MoveFirst
Do While Not rs.EOF
rs.edit
rs!Letter1 = True
rs.Update
rs.MoveNext
Loop
End If
Set rs = Nothing
End Sub
 
Thanks Roy! Your are a legend! Works perfectly! :eek:)

Thanks again! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top