dbTalk Databases Forums  

I am working in MS access 2007 , I have a subform contains two fields

comp.databases.ms-access comp.databases.ms-access


Discuss I am working in MS access 2007 , I have a subform contains two fields in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wisso
 
Posts: n/a

Default I am working in MS access 2007 , I have a subform contains two fields - 05-07-2010 , 03:30 AM






I am working in MS access 2007 , I have a subform contains two fields
customer name (type text) and customer selected (type yes/no) , one
of
these customer has a value 'ALL' , the question is :
is there a way when i click in the customer selected field that has
the customer name 'ALL' , to select all the records of the customer
(mean add tic in all customer selected) ?
any one could tell me how to do that ?

Reply With Quote
  #2  
Old   
Stuart McCall
 
Posts: n/a

Default Re: I am working in MS access 2007 , I have a subform contains two fields - 05-07-2010 , 05:22 AM






"Wisso" <wbazzoun (AT) gmail (DOT) com> wrote

Quote:
I am working in MS access 2007 , I have a subform contains two fields
customer name (type text) and customer selected (type yes/no) , one
of
these customer has a value 'ALL' , the question is :
is there a way when i click in the customer selected field that has
the customer name 'ALL' , to select all the records of the customer
(mean add tic in all customer selected) ?
any one could tell me how to do that ?
Put code like this in the checkbox's AfterUpdate event procedure:

Dim strSQL As String

If Me![customer selected] = True Then
If Me![customer name] = "ALL" Then
strSQL = "Update [My Table Name] Set [customer selected] = True;"
CurrentDb.Execute strSQL
Me.ReQuery
End If
End If

Substitute my example names with your own. What that does is run an update
SQL statement to check all the boxes if both [If] conditions are satisfied,
then it requery's the form so the modifications are visible.

(beware of word wrap - the "strSQL =" statement is all one line.)

Reply With Quote
  #3  
Old   
Krzysztof Naworyta
 
Posts: n/a

Default Re: I am working in MS access 2007 , I have a subform contains two fields - 05-07-2010 , 06:10 AM



Stuart McCall wrote:

Quote:
| I am working in MS access 2007 , I have a subform contains two fields
| customer name (type text) and customer selected (type yes/no) , one
| of
| these customer has a value 'ALL' , the question is :
| is there a way when i click in the customer selected field that has
| the customer name 'ALL' , to select all the records of the customer
| (mean add tic in all customer selected) ?
| any one could tell me how to do that ?

Put code like this in the checkbox's AfterUpdate event procedure:

Dim strSQL As String

If Me![customer selected] = True Then
If Me![customer name] = "ALL" Then
strSQL = "Update [My Table Name] Set [customer selected] =
True;" CurrentDb.Execute strSQL
Me.ReQuery
End If
End If

Substitute my example names with your own. What that does is run an
update SQL statement to check all the boxes if both [If] conditions
are satisfied, then it requery's the form so the modifications are
visible.
To avoid requering:

Private Sub customer_selected_AfterUpdate

dim k as boolean

k = Me!customer_selected

If Me![customer name] = "ALL" Then

With me.recordset.Clone
.MoveFirst
Do Until .Eof
if Nz(!customer_selected,0) <> k Then
.Edit
!customer_selected = k
.Update
end if
.moveNext
Loop
End With
end if

End Sub

--
KN

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: I am working in MS access 2007 , I have a subform contains twofields - 05-07-2010 , 09:46 AM



Wisso wrote:
Quote:
I am working in MS access 2007 , I have a subform contains two fields
customer name (type text) and customer selected (type yes/no) , one
of
these customer has a value 'ALL' , the question is :
is there a way when i click in the customer selected field that has
the customer name 'ALL' , to select all the records of the customer
(mean add tic in all customer selected) ?
any one could tell me how to do that ?
Usually I have a form/subform. The header of the main form may have a
field to filter on. I may have a default of all records. Then when it
changes I do something in the AfterUpdate event like
Dim strF as String
If strF <> "All" then strF = "CustomerType = " & Me.YourFldName
Me.Filter = strF
Me.FilterOn = (strF <> "")

You can refer to forms, instead of Me, if referring to subforms like
Forms!YourMainFormName!YourSubFormName.Form.Filter = ...
and for a field
Forms!YourMainFormName!YourSubFormName!TheFieldNam e...

I'm not sure why you'd have the customer name and type in a subform to
select all (what) records of a customer.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.