Multiline Form

M

Me

I have a multiline form displaying various file names
I want to be able to select a few files out of hundreds
of files and display only the ones selected by me.
When I select a record, I should be able to display
the record as selected so that I don't mark a record
twice.


Its something like ...

Order No. Details File Name Selected OpenFile

1 xxx abc Yes Button
2 xyx ttt Button
3 mmm mmm Yes Button

In the above example, after I select the 1st and 3rd
Orders when I click on Button it should open both the
files. I am able to open any number of files this way,
the only problem I am running into is how to initialize
Selected Field?

I will prefer if its not a database field, but if its
required, then I don't mind.

Any help will be highly appreciated!
-Me
 
G

Graham Mandeno

Hi Me

You cannot select non-contiguous records in a form, so there is really no
easy method that does not involve a field in a table. If you have only one
user at a time performing this function, then you can add a boolean (yes/no)
field to your table. If you have multiple concurrent users, then you will
need to use a linked temporary table, preferably in a separate database
file, one per user.

Another possibility is using a multiselect list box. If the records don't
need to be edited in situ on the form, then this would be a good way to go.
 
M

Marshall Barton

Me said:
I have a multiline form displaying various file names
I want to be able to select a few files out of hundreds
of files and display only the ones selected by me.
When I select a record, I should be able to display
the record as selected so that I don't mark a record
twice.


Its something like ...

Order No. Details File Name Selected OpenFile

1 xxx abc Yes Button
2 xyx ttt Button
3 mmm mmm Yes Button

In the above example, after I select the 1st and 3rd
Orders when I click on Button it should open both the
files. I am able to open any number of files this way,
the only problem I am running into is how to initialize
Selected Field?

I will prefer if its not a database field, but if its
required, then I don't mind.


A continuous form only has one control per value, so this
requires a Selected column in the table.

It is easy to initialize/reset the field for all records in
the table by executing an Update Query:

CurrentDb.Execute "UPDATE table SET Selected = 0"
 
A

Albert D. Kallal

You can use the following concept..and it works well:

Just bind your check box to a function. The code in the module is


Option Compare Database
Option Explicit

Dim colCheckBox As New Collection


Public Function IsChecked(vID As Variant) As Boolean

Dim lngID As Long

IsChecked = False

On Error GoTo exit1

lngID = colCheckBox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If

exit1:

End Function


So, bind the check box to the above function (use the key id). So, the

=IsChecked([id])

Now, place a in-visible button over the check box (you can't click on the
check box if it is bound to the above.

the code in the button click is:

If IsChecked(Me.ID) = False Then
colCheckBox.Add Me.ID, CStr(Me.ID)
Else
colCheckBox.Remove (CStr(Me.ID))
End If
Me.Check11.Requery


That is all you need...and presto... a un-bound check box.....

The list of selected boxes is of course the colCollection.

You can list it out like:

for i = 1 to colColleciton.Count

debug.Print colColleciton(i)

next i
 
M

Me

Hi Albert,

I created function IsChecked and bound it with the
check box. Then created an invisible button and put
the code as you mentioned. However, when I run the program
and click on checkbox/button, I get the error -
"Control can't be edited; its bound to the expression
IsChecked([id])"

Any suggestion? I have put msg in checkbox
click and checkbox_button click, looks like it isn't
going there at all.

Thank you very much!
-Me
 
A

Albert D. Kallal

You have to click on the invisible button to make the check box work...so,
you simply put the invisible button ON TOP of the check box....

Did not make that clear...but kind though it was obvious...sorry!
 
M

Me

Albert,

I had already done that way, I confirmed again after your
this posting, still I get the error -
"Control can't be edited, it's bound to the expression
IsChecked([Id])'

The check_box Properties are -
Control Source "=IsChecked([id])"
Visible Yes
Positions Left 7.2917
Top 0.125
Width 0.2083
Height 0.1667
Enabled Yes

Check_box_button Properties are -
Visible No
Positions Left 7.2917
Top 0.125
Width 0.2083
Height 0.1667
Enabled Yes

I have IsChecked(vID As Variant) function and
code for Check_box_button click. I have also put message
in the check_box_button the message doesn't show up.

I should get the message upon click on the
check_box_button?

Thank you,
-Me
 
A

Albert D. Kallal

The button has to be visible.

So, you set the buttons Visible setting = Yes, but must set the buttons
"transparent" setting to yes also.

Note that any control that is NOT visible can't be clicked on.
 
M

Me

Albert,

I tried button properties as Transparent yes
Visible Yes

Then I get the following error -

"Compile error - Method or Data Member not found"

Here is snippet of checkbox_button_click

Private Sub CheckBox_button_Click()
MsgBox "In checkbox button click "
If IsChecked(Me.id) = False Then
colCheckBox.Add Me.id, CStr(Me.id)
Else
colCheckBox.Remove (CStr(Me.id))
End If
Me.Check11.Requery
End Sub


I haven't put in my code yet. I just want to see if this
works.

When I click on the button, shouldn't I get the message
at least?
 
A

Albert D. Kallal

For the time being, lets just forget about the transparent stuff. Lets just
place a standard button beside the check box, and then the code there.

Once we get the button working..then we will attempt to get the button
transparent, and move it "over" the check box. But, for now..lets just go
with a 100% standard normal button placed with room to spare on the
continuous form. Sure, lets just place this button beside the check box. We
then put the code in for the button click event.

Make sure you let the code builder create the name of the button event...and
paste you code IN SIDE of this code

MsgBox "In checkbox button click "
If IsChecked(Me.id) = False Then
colCheckBox.Add Me.id, CStr(Me.id)
Else
colCheckBox.Remove (CStr(Me.id))
End If

Me.NameOfCheckBoxContorlGoesHere.Requery

(let the system create the button event name etc.).
 
G

Graham Mandeno

I really like your idea of using a collection, Albert :)

Me:

You must remove the ability to click on the actual checkbox. To do this,
set its Enabled property to "No", and also set its Locked property to "Yes",
otherwise it will be greyed out.

The command button must be visible (in the sense of the Visible property)
otherwise you won't be able to click on it, but should be "invisible" (in
the sense of not being able to be seen) by setting the Transparent property.

Then everything should work.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Me said:
Albert,

I had already done that way, I confirmed again after your
this posting, still I get the error -
"Control can't be edited, it's bound to the expression
IsChecked([Id])'

The check_box Properties are -
Control Source "=IsChecked([id])"
Visible Yes
Positions Left 7.2917
Top 0.125
Width 0.2083
Height 0.1667
Enabled Yes
our code,
Check_box_button Properties are -
Visible No
Positions Left 7.2917
Top 0.125
Width 0.2083
Height 0.1667
Enabled Yes

I have IsChecked(vID As Variant) function and
code for Check_box_button click. I have also put message
in the check_box_button the message doesn't show up.

I should get the message upon click on the
check_box_button?

Thank you,
-Me
-----Original Message-----
You have to click on the invisible button to make the check box work...so,
you simply put the invisible button ON TOP of the check box....

Did not make that clear...but kind though it was obvious...sorry!


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.
 
A

Albert D. Kallal

I really like your idea of using a collection, Albert :)


You must remove the ability to click on the actual checkbox. To do this,
set its Enabled property to "No", and also set its Locked property to
"Yes",
otherwise it will be greyed out.

Actually, what I do is put the transparent button ON TOP of the check
box..and then users never get a chance to click on it!!

(but...yes...I see your point...).
The command button must be visible (in the sense of the Visible property)

Correct.....so we got Visible = Yes...but so is transparent = Yes. So, the
idea here is not even to bother changing the check box.

Usually the transparent setting is used for placing a button on some graphic
or other area of a form that you want to make clickable..but not see the
button. However, this also works in a continues form..and you can put the
button on TOP of the check box....
 
M

Me

Albert,

I tried your suggestion listed here, I get error -
"Method or data member not found" Me.Id.

This is 'cause we need to get the id by running
IsChecked([Id]). How can I invoke it? I tried something,
it didn't work.

Thank you,
-Me
 
M

Me

Albert,

I deleted the code for check_box_click and reenterd, it
works now. But the problem is I would like to see
the check box checked out when users click on the button
or button should be highlighted to distinguish from
others. Any ideas on that? I am also trying, but thought
of checking with you as well.

Thank you for your time!
-Me
-----Original Message-----
Albert,

I tried your suggestion listed here, I get error -
"Method or data member not found" Me.Id.

This is 'cause we need to get the id by running
IsChecked([Id]). How can I invoke it? I tried something,
it didn't work.

Thank you,
-Me
-----Original Message-----
For the time being, lets just forget about the transparent stuff. Lets just
place a standard button beside the check box, and then the code there.

Once we get the button working..then we will attempt to get the button
transparent, and move it "over" the check box. But, for now..lets just go
with a 100% standard normal button placed with room to spare on the
continuous form. Sure, lets just place this button beside the check box. We
then put the code in for the button click event.

Make sure you let the code builder create the name of the button event...and
paste you code IN SIDE of this code

MsgBox "In checkbox button click "
If IsChecked(Me.id) = False Then
colCheckBox.Add Me.id, CStr(Me.id)
Else
colCheckBox.Remove (CStr(Me.id))
End If

Me.NameOfCheckBoxContorlGoesHere.Requery

(let the system create the button event name etc.).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn



.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top