Make UNBOUND ctrl act like BOUND ctrl!

  • Thread starter Thread starter Bill Mitchell
  • Start date Start date
B

Bill Mitchell

Hi,

I've been messin around with this for days and I think I
have come up with a very cool and very easy method for
making an Unbound Control on a continuous form display
pretty much any value when the current record has the
focus on that record only and no others.

This works great if you are trying to make the current
line a different color or check a box for the current
line.

Actually, I'm not really sure why all of this works, but
it does and takes almost no code at all :)

Example:
Lets say we have a continuous form based upon a table
called "Contact". Let's say the Primary Key on that
table is called "ContactID". ContactID exists as a field
on our continuous form.

We need to place two UNBOUND fields on our form:
1. A field called "ctlCurrentRecord"
2. A Checkbox call "ContactSelector"

Our goal will be to make ContactSelector 'checked' when
we select the active record but 'unchecked' for all
unselected records.

Ok, now in your OnCurrent Event for your continuous form,
place this code:

'Set Record Selector:
Me.ctlCurrentRecord = Me.SelTop
If IsNull(Me![ContactID]) Then
Else
Me.ContactID.Tag = Me.ContactID
End If

Finally, set the value of your "ContactSelector" unbound
checkbox to:

=IIf([Form].[KeywordID].[Tag]=[Form].[KeywordID],-1,0)

Ok, now when you select a record, the checkbox for that
record will be checked and all others unchecked. When
you leave that record and go to another record, it works
too.

Pretty cool huh?

Lastly, if you want to change a row color using this, try
this way:

Make "ContactSelector" a textbox rather than a checkbox.
Set the font to "Terminal" and the forecolor for the font
to whatever color you want your row to be. Now set the
value of "ContactSelector" to:

=IIf([Form].[ContactID].[Tag]=[Form].
[ContactID],"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Û",Null)

You will need to make your form background WHITE and the
your field backcolors set to the same color as
your "ContactSelector" forecolor and set to Transparent.
Place "ContactSelector" behind the fields you want to
change color when the row is selected.

Anyway, it works like a charm and almost no code.

Last Comment:

You may be wondering why I need the "ctlCurrentRecord" to
be set to me.SelTop for each record selected. Honestly,
I'm not sure, but I know it doesnt work without it :)

Bill

Any MVP comments appreciated.
 
What's wrong with using record selectors and/ or conditional formatting?

Andrew

Hi,

I've been messin around with this for days and I think I
have come up with a very cool and very easy method for
making an Unbound Control on a continuous form display
pretty much any value when the current record has the
focus on that record only and no others.

This works great if you are trying to make the current
line a different color or check a box for the current
line.

Actually, I'm not really sure why all of this works, but
it does and takes almost no code at all :)

Example:
Lets say we have a continuous form based upon a table
called "Contact". Let's say the Primary Key on that
table is called "ContactID". ContactID exists as a field
on our continuous form.

We need to place two UNBOUND fields on our form:
1. A field called "ctlCurrentRecord"
2. A Checkbox call "ContactSelector"

Our goal will be to make ContactSelector 'checked' when
we select the active record but 'unchecked' for all
unselected records.

Ok, now in your OnCurrent Event for your continuous form,
place this code:

'Set Record Selector:
Me.ctlCurrentRecord = Me.SelTop
If IsNull(Me![ContactID]) Then
Else
Me.ContactID.Tag = Me.ContactID
End If

Finally, set the value of your "ContactSelector" unbound
checkbox to:

=IIf([Form].[KeywordID].[Tag]=[Form].[KeywordID],-1,0)

Ok, now when you select a record, the checkbox for that
record will be checked and all others unchecked. When
you leave that record and go to another record, it works
too.

Pretty cool huh?

Lastly, if you want to change a row color using this, try
this way:

Make "ContactSelector" a textbox rather than a checkbox.
Set the font to "Terminal" and the forecolor for the font
to whatever color you want your row to be. Now set the
value of "ContactSelector" to:

=IIf([Form].[ContactID].[Tag]=[Form].
[ContactID],"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Û",Null)

You will need to make your form background WHITE and the
your field backcolors set to the same color as
your "ContactSelector" forecolor and set to Transparent.
Place "ContactSelector" behind the fields you want to
change color when the row is selected.

Anyway, it works like a charm and almost no code.

Last Comment:

You may be wondering why I need the "ctlCurrentRecord" to
be set to me.SelTop for each record selected. Honestly,
I'm not sure, but I know it doesnt work without it :)

Bill

Any MVP comments appreciated.
 
Your second technique is essentially the same as described in
http://www.mvps.org/access/forms/frm0047.htm at "The Access Web". There's
also http://www.mvps.org/access/forms/frm0024.htm that discusses this.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Hi,

I've been messin around with this for days and I think I
have come up with a very cool and very easy method for
making an Unbound Control on a continuous form display
pretty much any value when the current record has the
focus on that record only and no others.

This works great if you are trying to make the current
line a different color or check a box for the current
line.

Actually, I'm not really sure why all of this works, but
it does and takes almost no code at all :)

Example:
Lets say we have a continuous form based upon a table
called "Contact". Let's say the Primary Key on that
table is called "ContactID". ContactID exists as a field
on our continuous form.

We need to place two UNBOUND fields on our form:
1. A field called "ctlCurrentRecord"
2. A Checkbox call "ContactSelector"

Our goal will be to make ContactSelector 'checked' when
we select the active record but 'unchecked' for all
unselected records.

Ok, now in your OnCurrent Event for your continuous form,
place this code:

'Set Record Selector:
Me.ctlCurrentRecord = Me.SelTop
If IsNull(Me![ContactID]) Then
Else
Me.ContactID.Tag = Me.ContactID
End If

Finally, set the value of your "ContactSelector" unbound
checkbox to:

=IIf([Form].[KeywordID].[Tag]=[Form].[KeywordID],-1,0)

Ok, now when you select a record, the checkbox for that
record will be checked and all others unchecked. When
you leave that record and go to another record, it works
too.

Pretty cool huh?

Lastly, if you want to change a row color using this, try
this way:

Make "ContactSelector" a textbox rather than a checkbox.
Set the font to "Terminal" and the forecolor for the font
to whatever color you want your row to be. Now set the
value of "ContactSelector" to:

=IIf([Form].[ContactID].[Tag]=[Form].
[ContactID],"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Û",Null)

You will need to make your form background WHITE and the
your field backcolors set to the same color as
your "ContactSelector" forecolor and set to Transparent.
Place "ContactSelector" behind the fields you want to
change color when the row is selected.

Anyway, it works like a charm and almost no code.

Last Comment:

You may be wondering why I need the "ctlCurrentRecord" to
be set to me.SelTop for each record selected. Honestly,
I'm not sure, but I know it doesnt work without it :)

Bill

Any MVP comments appreciated.
 
Well no, actually its not. The technique used at Access
Web is based upon a Function GetLineNumber() which can be
quite cumbersom if used alot. This gets around that but
uses the same basic concept.

-----Original Message-----
Your second technique is essentially the same as described in
http://www.mvps.org/access/forms/frm0047.htm at "The Access Web". There's
also http://www.mvps.org/access/forms/frm0024.htm that discusses this.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Hi,

I've been messin around with this for days and I think I
have come up with a very cool and very easy method for
making an Unbound Control on a continuous form display
pretty much any value when the current record has the
focus on that record only and no others.

This works great if you are trying to make the current
line a different color or check a box for the current
line.

Actually, I'm not really sure why all of this works, but
it does and takes almost no code at all :)

Example:
Lets say we have a continuous form based upon a table
called "Contact". Let's say the Primary Key on that
table is called "ContactID". ContactID exists as a field
on our continuous form.

We need to place two UNBOUND fields on our form:
1. A field called "ctlCurrentRecord"
2. A Checkbox call "ContactSelector"

Our goal will be to make ContactSelector 'checked' when
we select the active record but 'unchecked' for all
unselected records.

Ok, now in your OnCurrent Event for your continuous form,
place this code:

'Set Record Selector:
Me.ctlCurrentRecord = Me.SelTop
If IsNull(Me![ContactID]) Then
Else
Me.ContactID.Tag = Me.ContactID
End If

Finally, set the value of your "ContactSelector" unbound
checkbox to:

=IIf([Form].[KeywordID].[Tag]=[Form].[KeywordID],-1,0)

Ok, now when you select a record, the checkbox for that
record will be checked and all others unchecked. When
you leave that record and go to another record, it works
too.

Pretty cool huh?

Lastly, if you want to change a row color using this, try
this way:

Make "ContactSelector" a textbox rather than a checkbox.
Set the font to "Terminal" and the forecolor for the font
to whatever color you want your row to be. Now set the
value of "ContactSelector" to:

=IIf([Form].[ContactID].[Tag]=[Form].
[ContactID],"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Û
Û",Null)

You will need to make your form background WHITE and the
your field backcolors set to the same color as
your "ContactSelector" forecolor and set to Transparent.
Place "ContactSelector" behind the fields you want to
change color when the row is selected.

Anyway, it works like a charm and almost no code.

Last Comment:

You may be wondering why I need the "ctlCurrentRecord" to
be set to me.SelTop for each record selected. Honestly,
I'm not sure, but I know it doesnt work without it :)

Bill

Any MVP comments appreciated.




.
 
Whats wrong with record selectors? Besides the fact they
are big, ungainly, ugly and cumbersome? Not much I
guess. Also, it is nice to be abl to turn the color of
the current line different, and you cant do THAT with
conditional formatting.

-----Original Message-----
What's wrong with using record selectors and/ or conditional formatting?

Andrew

Hi,

I've been messin around with this for days and I think I
have come up with a very cool and very easy method for
making an Unbound Control on a continuous form display
pretty much any value when the current record has the
focus on that record only and no others.

This works great if you are trying to make the current
line a different color or check a box for the current
line.

Actually, I'm not really sure why all of this works, but
it does and takes almost no code at all :)

Example:
Lets say we have a continuous form based upon a table
called "Contact". Let's say the Primary Key on that
table is called "ContactID". ContactID exists as a field
on our continuous form.

We need to place two UNBOUND fields on our form:
1. A field called "ctlCurrentRecord"
2. A Checkbox call "ContactSelector"

Our goal will be to make ContactSelector 'checked' when
we select the active record but 'unchecked' for all
unselected records.

Ok, now in your OnCurrent Event for your continuous form,
place this code:

'Set Record Selector:
Me.ctlCurrentRecord = Me.SelTop
If IsNull(Me![ContactID]) Then
Else
Me.ContactID.Tag = Me.ContactID
End If

Finally, set the value of your "ContactSelector" unbound
checkbox to:

=IIf([Form].[KeywordID].[Tag]=[Form].[KeywordID],-1,0)

Ok, now when you select a record, the checkbox for that
record will be checked and all others unchecked. When
you leave that record and go to another record, it works
too.

Pretty cool huh?

Lastly, if you want to change a row color using this, try
this way:

Make "ContactSelector" a textbox rather than a checkbox.
Set the font to "Terminal" and the forecolor for the font
to whatever color you want your row to be. Now set the
value of "ContactSelector" to:

=IIf([Form].[ContactID].[Tag]=[Form].
[ContactID],"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Û
Û",Null)

You will need to make your form background WHITE and the
your field backcolors set to the same color as
your "ContactSelector" forecolor and set to Transparent.
Place "ContactSelector" behind the fields you want to
change color when the row is selected.

Anyway, it works like a charm and almost no code.

Last Comment:

You may be wondering why I need the "ctlCurrentRecord" to
be set to me.SelTop for each record selected. Honestly,
I'm not sure, but I know it doesnt work without it :)

Bill

Any MVP comments appreciated.




.
 
Back
Top