3 VERY SIMPLE QUESTIONS... you can probably help me with this!

T

Trial & Error

I hope people dont mind me posting a couple questions here... i think they
are probably very simple to asnwer.

1)How do I get a toggle button to appear with text on it that corresponds to
the buttons current condition. I know how to get text to appear on it when
clicked... But the form I have one on is used to edit a booking, and
therefore I need the button to show up with its current status noted. (The
button appears depressed... so I know it is triggered... I would just like it
to say "YES" on it"

2) I am using a "medium date" format on a feild. ie. 10-oct-05.
I would like to enter a parameter in a query that would return all results
for a certain month. ie DEC. How do I create this parameter using my current
date format

3) What is the most simple code for having Microsolft outlook launch when a
feild is clicked. I have an email feild and would like to have Outlook launch
if it is double clicked.

Thanks to anyone who can answer any of these....
 
T

Trial & Error

Ok... solved question # 3 I have the email code... oulook opens in the
default window.

only 2 questions left now
 
D

Dirk Goldgar

Trial & Error said:
I hope people dont mind me posting a couple questions here... i think
they are probably very simple to asnwer.

1)How do I get a toggle button to appear with text on it that
corresponds to the buttons current condition. I know how to get text
to appear on it when clicked... But the form I have one on is used to
edit a booking, and therefore I need the button to show up with its
current status noted. (The button appears depressed... so I know it
is triggered... I would just like it to say "YES" on it"

If the button's caption changes when it's clicked, you must have code in
one of the button's events: AfterUpdate (my preference), or Click, that
changes the caption. For example, you may have an event procedure like
this:

Private Sub tglMyButton_AfterUpdate()

With Me!tglMyButton
If .Value = 0 Then
.Caption = "No"
Else
.Caption = "Yes"
End If
End With

End Sub

To get the caption to reflect the state of its bound field when you
first navigate to a new record, you need to excecute the same code in
the form's Current event. Rather than repeat all the code, you can just
call the button's AfterUpdate event procedure directly:

Private Sub Form_Current()

Call tglMyButton_AfterUpdate

End Sub
2) I am using a "medium date" format on a feild. ie. 10-oct-05.
I would like to enter a parameter in a query that would return all
results for a certain month. ie DEC. How do I create this parameter
using my current date format

The date *format* wouldn't be relevant, so long as it's a date/time
field. Your query could look something like this, which requires them
to enter a month number, not a name:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
[Enter month number (1-12):];

If you want your users to have more freedom at the parameter prompt, so
they can enter month numbers, month names, or standard month
abbreviations, you can use something like this:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
Month([Enter month name/abbreviation:] & "-1");
3) What is the most simple code for having Microsolft outlook launch
when a feild is clicked. I have an email feild and would like to have
Outlook launch if it is double clicked.

Assuming that Outlook is the default mail client (it isn't, on my PC,
because I use Outlook Express instead), this ought to do it:

'----- start of code -----
Private Sub EmailAddress_DblClick(Cancel As Integer)

Dim strEmail As String

If Not IsNull(Me.EmailAddress) Then
strEmail = Me.EmailAddress
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If

End Sub

'----- end of code -----

The above code will open the default e-mail client. Usually, that's
what you want to do. If you really want to open Outlook, even if the
user is using some other e-mail client, you'll have to take a different
approach.
 
F

fredg

I hope people dont mind me posting a couple questions here... i think they
are probably very simple to asnwer.

1)How do I get a toggle button to appear with text on it that corresponds to
the buttons current condition. I know how to get text to appear on it when
clicked... But the form I have one on is used to edit a booking, and
therefore I need the button to show up with its current status noted. (The
button appears depressed... so I know it is triggered... I would just like it
to say "YES" on it"

Code the toggle button's click event:
If Me![ToggleName].Caption = "Yes" Then
Me![ToggleName].Caption = "No"
Else
Me![ToggleName].Caption = "Yes"
End If
2) I am using a "medium date" format on a feild. ie. 10-oct-05.
I would like to enter a parameter in a query that would return all results
for a certain month. ie DEC. How do I create this parameter using my current
date format

The actual format of the date is irrelevant.

Add a new column to the query.
Exp:Format([DateField],"mm/yyyy")
As criteria for this column:
Format([Enter month/year],"mm/yyyy")

This has the advantage of allowing the user to select the year as well
as the month.
 
T

Trial & Error

WOW... the man with the answers...
Appreciate it

Im going to run through each of those now... the email I beleive I have
solved. The other two I will report back on

thanks again for all the help!

Cheers

Dirk Goldgar said:
Trial & Error said:
I hope people dont mind me posting a couple questions here... i think
they are probably very simple to asnwer.

1)How do I get a toggle button to appear with text on it that
corresponds to the buttons current condition. I know how to get text
to appear on it when clicked... But the form I have one on is used to
edit a booking, and therefore I need the button to show up with its
current status noted. (The button appears depressed... so I know it
is triggered... I would just like it to say "YES" on it"

If the button's caption changes when it's clicked, you must have code in
one of the button's events: AfterUpdate (my preference), or Click, that
changes the caption. For example, you may have an event procedure like
this:

Private Sub tglMyButton_AfterUpdate()

With Me!tglMyButton
If .Value = 0 Then
.Caption = "No"
Else
.Caption = "Yes"
End If
End With

End Sub

To get the caption to reflect the state of its bound field when you
first navigate to a new record, you need to excecute the same code in
the form's Current event. Rather than repeat all the code, you can just
call the button's AfterUpdate event procedure directly:

Private Sub Form_Current()

Call tglMyButton_AfterUpdate

End Sub
2) I am using a "medium date" format on a feild. ie. 10-oct-05.
I would like to enter a parameter in a query that would return all
results for a certain month. ie DEC. How do I create this parameter
using my current date format

The date *format* wouldn't be relevant, so long as it's a date/time
field. Your query could look something like this, which requires them
to enter a month number, not a name:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
[Enter month number (1-12):];

If you want your users to have more freedom at the parameter prompt, so
they can enter month numbers, month names, or standard month
abbreviations, you can use something like this:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
Month([Enter month name/abbreviation:] & "-1");
3) What is the most simple code for having Microsolft outlook launch
when a feild is clicked. I have an email feild and would like to have
Outlook launch if it is double clicked.

Assuming that Outlook is the default mail client (it isn't, on my PC,
because I use Outlook Express instead), this ought to do it:

'----- start of code -----
Private Sub EmailAddress_DblClick(Cancel As Integer)

Dim strEmail As String

If Not IsNull(Me.EmailAddress) Then
strEmail = Me.EmailAddress
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If

End Sub

'----- end of code -----

The above code will open the default e-mail client. Usually, that's
what you want to do. If you really want to open Outlook, even if the
user is using some other e-mail client, you'll have to take a different
approach.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
T

Trial & Error

Dirk,

Ive run into a problem with your toggle button suggestion.
I do have some code in the toggle buttons "On Click". It looks like this:

Private Sub Informed_Instructor_Click()
Dim bShow As Boolean

bShow = Nz(Me.Informed_Instructor.Value, False)

Me.Informed_Instructor.Caption = IIf(bShow, "YES", "NO")
End Sub

You suggested placing more code in the buttons "Current Event"... i however
seem to not have a current event option?!?!
I have:
On Enter
On Ext
On Get Focus
On Lost Focus
etc...

but no Current listing as an event.

Which even should I deal with instead?


Dirk Goldgar said:
Trial & Error said:
I hope people dont mind me posting a couple questions here... i think
they are probably very simple to asnwer.

1)How do I get a toggle button to appear with text on it that
corresponds to the buttons current condition. I know how to get text
to appear on it when clicked... But the form I have one on is used to
edit a booking, and therefore I need the button to show up with its
current status noted. (The button appears depressed... so I know it
is triggered... I would just like it to say "YES" on it"

If the button's caption changes when it's clicked, you must have code in
one of the button's events: AfterUpdate (my preference), or Click, that
changes the caption. For example, you may have an event procedure like
this:

Private Sub tglMyButton_AfterUpdate()

With Me!tglMyButton
If .Value = 0 Then
.Caption = "No"
Else
.Caption = "Yes"
End If
End With

End Sub

To get the caption to reflect the state of its bound field when you
first navigate to a new record, you need to excecute the same code in
the form's Current event. Rather than repeat all the code, you can just
call the button's AfterUpdate event procedure directly:

Private Sub Form_Current()

Call tglMyButton_AfterUpdate

End Sub
2) I am using a "medium date" format on a feild. ie. 10-oct-05.
I would like to enter a parameter in a query that would return all
results for a certain month. ie DEC. How do I create this parameter
using my current date format

The date *format* wouldn't be relevant, so long as it's a date/time
field. Your query could look something like this, which requires them
to enter a month number, not a name:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
[Enter month number (1-12):];

If you want your users to have more freedom at the parameter prompt, so
they can enter month numbers, month names, or standard month
abbreviations, you can use something like this:

SELECT * FROM MyTable
WHERE Month(MyDateField) =
Month([Enter month name/abbreviation:] & "-1");
3) What is the most simple code for having Microsolft outlook launch
when a feild is clicked. I have an email feild and would like to have
Outlook launch if it is double clicked.

Assuming that Outlook is the default mail client (it isn't, on my PC,
because I use Outlook Express instead), this ought to do it:

'----- start of code -----
Private Sub EmailAddress_DblClick(Cancel As Integer)

Dim strEmail As String

If Not IsNull(Me.EmailAddress) Then
strEmail = Me.EmailAddress
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If

End Sub

'----- end of code -----

The above code will open the default e-mail client. Usually, that's
what you want to do. If you really want to open Outlook, even if the
user is using some other e-mail client, you'll have to take a different
approach.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Trial & Error said:
Dirk,

Ive run into a problem with your toggle button suggestion.
I do have some code in the toggle buttons "On Click". It looks like
this:

Private Sub Informed_Instructor_Click()
Dim bShow As Boolean

bShow = Nz(Me.Informed_Instructor.Value, False)

Me.Informed_Instructor.Caption = IIf(bShow, "YES", "NO")
End Sub

You suggested placing more code in the buttons "Current Event"... i
however seem to not have a current event option?!?!
I have:
On Enter
On Ext
On Get Focus
On Lost Focus
etc...

but no Current listing as an event.

Which even should I deal with instead?

I said to use the *form's* Current event, not the button's Current
event. As you've observed, controls have no Current event.
 
T

Trial & Error

Hah... so you did... sorry about that

Ok.. heres what Im trying, but im not having much luck.

My On Click for the toggle button in question looks like this

If Me![Informed Instructor].Caption = "Yes" Then
Me![Informed Instructor].Caption = "No"
Else
Me![Informed Instructor].Caption = "Yes"
End If

That gets the Yes & No message to switch accordingly...
When I use the same code for the forms On current, i do not get the desired
result.

Instead, the toggle buttons seem to just flip back and forth between yes and
no as i scroll through the records. The button status changes from pushed to
not pushed.. but the yes's and no's simply alternate... they dont coorespond
with the state of the button at all.

The buttons I am trying to add code to are called
"Informed Instructor" &
"Instructor Confirmed"
i am hoping that I can have both of them read either "yes" or "no" depending
on their status... and I am also hoping that when the form is opened in edit
mode, that the buttons will read yes or no depending on their existing state.
(This is what the On current takes care of??? i think?)

Sorry to trouble you with this...... i seem to be stuck.
 
D

Dirk Goldgar

Trial & Error said:
Hah... so you did... sorry about that

Ok.. heres what Im trying, but im not having much luck.

My On Click for the toggle button in question looks like this

If Me![Informed Instructor].Caption = "Yes" Then
Me![Informed Instructor].Caption = "No"
Else
Me![Informed Instructor].Caption = "Yes"
End If

That gets the Yes & No message to switch accordingly...
When I use the same code for the forms On current, i do not get the
desired result.

No, it wouldn't. The connection between the button and the content of
the field to which it's bound is lost. Your code should not use the
current state of the button's caption; it should use the value of the
button control itself.

Do this:

1. Remove the code from the button's Click event. I really recommend
using the AfterUpdate event instead.

2. Insert this code for the button's AfterUpdate event:

'----- start of code -----
Private Sub Informed_Instructor_AfterUpdate()

With Me![Informed Instructor]
If .Value = 0 Then
.Caption = "No"
Else
.Caption = "Yes"
End If
End With

End Sub
'----- end of code -----

Then use the code that I gave you for the form's Current event, except
that you'd revise it to call the correct procedure name:

Call Informed_Instructor_AfterUpdate

I'm assuming thar this control is bound to a yes/no field in the table.
If that's not the case, I need to know what value of the field
corresponds to "Yes" and what value corresponds to "No".
Instead, the toggle buttons seem to just flip back and forth between
yes and no as i scroll through the records. The button status changes
from pushed to not pushed.. but the yes's and no's simply
alternate... they dont coorespond with the state of the button at all.

The buttons I am trying to add code to are called
"Informed Instructor" &
"Instructor Confirmed"

The code for the other button should be the same except for the name of
the control and the procedure.
i am hoping that I can have both of them read either "yes" or "no"
depending on their status... and I am also hoping that when the form
is opened in edit mode, that the buttons will read yes or no
depending on their existing state. (This is what the On current takes
care of??? i think?)

Yes. This should work.
Sorry to trouble you with this...... i seem to be stuck.

No problem. Have faith -- you're almost there.
 
Top