Missing a line in my Code

B

Bob

After the MsgBox line I must be missing something for it to work, and can I
change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

Played around with it and seem to get it to go now
Does this look correct to you???.....Thanks bob
Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
Exit Sub
End If
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click


End Sub
 
G

Graham Mandeno

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give the user
a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as the
buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) = vbYes
Then

This will display Yes and No buttons and a question mark icon. The function
will return the value vbYes only if the "Yes" button was clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your entire
procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If
 
B

Bob

Oops that was closing my application down, Does this code look ok?
Asks a question first before proceeding to a new form!
Private Sub Command98_Click()
If MsgBox("Does this Horse have a Client!", vbQuestion + vbYesNo) = vbNo
Then


Exit Sub
End If
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
 
B

Bob

Thanx Graham got it now!

Graham Mandeno said:
Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give the
user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as the
buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) = vbYes
Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your entire
procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
After the MsgBox line I must be missing something for it to work, and can
I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

Graham I have a form that has a combo Box that has 2 options (Active &
Finished)cbStatus, and another combo box that list clients, is possible to
lock The clients Combo Box cbOwnerID when it is in active mode and unlock
when in finished mode
Thanks Bob (Papakura)

Bob said:
Thanx Graham got it now!

Graham Mandeno said:
Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give the
user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as the
buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) = vbYes
Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your entire
procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
After the MsgBox line I must be missing something for it to work, and
can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
G

Graham Mandeno

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for cbStatus, AND
in the Current event for your form, add the following code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If not,
you might consider making it a boolean (yes/no) field bound to a checkbox.
This would save real estate on your form and would probably make the user
interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Bob said:
Graham I have a form that has a combo Box that has 2 options (Active &
Finished)cbStatus, and another combo box that list clients, is possible to
lock The clients Combo Box cbOwnerID when it is in active mode and unlock
when in finished mode
Thanks Bob (Papakura)

Bob said:
Thanx Graham got it now!

Graham Mandeno said:
Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give the
user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as the
buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) = vbYes
Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your entire
procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work, and
can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

No Graham just has the two (Active,Finished), should this be done another
way?.....Regards Bob Vance

Graham Mandeno said:
Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for cbStatus,
AND in the Current event for your form, add the following code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If not,
you might consider making it a boolean (yes/no) field bound to a checkbox.
This would save real estate on your form and would probably make the user
interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Bob said:
Graham I have a form that has a combo Box that has 2 options (Active &
Finished)cbStatus, and another combo box that list clients, is possible
to lock The clients Combo Box cbOwnerID when it is in active mode and
unlock when in finished mode
Thanks Bob (Papakura)

Bob said:
Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give the
user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as
the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work, and
can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
Bob said:
No Graham just has the two (Active,Finished), should this be done another
way?.....Regards Bob Vance

Graham Mandeno said:
Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for cbStatus,
AND in the Current event for your form, add the following code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If not,
you might consider making it a boolean (yes/no) field bound to a
checkbox. This would save real estate on your form and would probably
make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Bob said:
Graham I have a form that has a combo Box that has 2 options (Active &
Finished)cbStatus, and another combo box that list clients, is possible
to lock The clients Combo Box cbOwnerID when it is in active mode and
unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give
the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as
the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work, and
can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
G

Graham Mandeno

Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top left,
or use Ctrl-R). Now, in the properties window, on the Event tab, scroll
down until you see "On Current". Type a left-square-bracket "[" in the cell
and "[Event Procedure]" should appear. Then click the three dots button to
the right of the cell. The VBA code window should open showing (among other
things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's where the
code goes.

What I meant about a boolean field was to have a yes/no field in your table
named "Finished". You can then bind this to a checkbox on your form and a
single click will put a tick in the box (Finished) or clear it (Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but they
have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Bob said:
Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
Bob said:
No Graham just has the two (Active,Finished), should this be done another
way?.....Regards Bob Vance

Graham Mandeno said:
Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for cbStatus,
AND in the Current event for your form, add the following code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If
not, you might consider making it a boolean (yes/no) field bound to a
checkbox. This would save real estate on your form and would probably
make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options (Active &
Finished)cbStatus, and another combo box that list clients, is possible
to lock The clients Combo Box cbOwnerID when it is in active mode and
unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give
the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as
the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work,
and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

Graham this is what is in there:
Private Sub Form_Current()
subShowValues
End Sub

Graham Mandeno said:
Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top left,
or use Ctrl-R). Now, in the properties window, on the Event tab, scroll
down until you see "On Current". Type a left-square-bracket "[" in the
cell and "[Event Procedure]" should appear. Then click the three dots
button to the right of the cell. The VBA code window should open showing
(among other things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's where
the code goes.

What I meant about a boolean field was to have a yes/no field in your
table named "Finished". You can then bind this to a checkbox on your form
and a single click will put a tick in the box (Finished) or clear it
(Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but
they have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Bob said:
Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
Bob said:
No Graham just has the two (Active,Finished), should this be done
another way?.....Regards Bob Vance

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for
cbStatus, AND in the Current event for your form, add the following
code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If
not, you might consider making it a boolean (yes/no) field bound to a
checkbox. This would save real estate on your form and would probably
make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options (Active
& Finished)cbStatus, and another combo box that list clients, is
possible to lock The clients Combo Box cbOwnerID when it is in active
mode and unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give
the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such as
the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work,
and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

I do have this code on the delete button of client:

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click
Dim nRtnValue As Integer
nRtnValue = MsgBox("Are you sure you want to Delete this Client ?
Horse must have a least one Client!", vbCritical + vbYesNo, "Delete Client")
If nRtnValue = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click
End If

End Sub
 
G

Graham Mandeno

So, your Form_Current event proc is already doing something (i.e. calling
the Sub named "subShowvalues")

No matter - you want it to also do something else, so add your line of code
after that one.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
Graham this is what is in there:
Private Sub Form_Current()
subShowValues
End Sub

Graham Mandeno said:
Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top
left, or use Ctrl-R). Now, in the properties window, on the Event tab,
scroll down until you see "On Current". Type a left-square-bracket "["
in the cell and "[Event Procedure]" should appear. Then click the three
dots button to the right of the cell. The VBA code window should open
showing (among other things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's where
the code goes.

What I meant about a boolean field was to have a yes/no field in your
table named "Finished". You can then bind this to a checkbox on your
form and a single click will put a tick in the box (Finished) or clear it
(Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but
they have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Bob said:
Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
No Graham just has the two (Active,Finished), should this be done
another way?.....Regards Bob Vance

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for
cbStatus, AND in the Current event for your form, add the following
code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If
not, you might consider making it a boolean (yes/no) field bound to a
checkbox. This would save real estate on your form and would probably
make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options (Active
& Finished)cbStatus, and another combo box that list clients, is
possible to lock The clients Combo Box cbOwnerID when it is in active
mode and unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to give
the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such
as the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon. The
function will return the value vbYes only if the "Yes" button was
clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work,
and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

I got a compile error on Finished , member not found
Thanks..Bob

Graham Mandeno said:
So, your Form_Current event proc is already doing something (i.e. calling
the Sub named "subShowvalues")

No matter - you want it to also do something else, so add your line of
code after that one.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
Graham this is what is in there:
Private Sub Form_Current()
subShowValues
End Sub

Graham Mandeno said:
Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top
left, or use Ctrl-R). Now, in the properties window, on the Event tab,
scroll down until you see "On Current". Type a left-square-bracket "["
in the cell and "[Event Procedure]" should appear. Then click the three
dots button to the right of the cell. The VBA code window should open
showing (among other things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's where
the code goes.

What I meant about a boolean field was to have a yes/no field in your
table named "Finished". You can then bind this to a checkbox on your
form and a single click will put a tick in the box (Finished) or clear
it (Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but
they have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
No Graham just has the two (Active,Finished), should this be done
another way?.....Regards Bob Vance

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for
cbStatus, AND in the Current event for your form, add the following
code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If
not, you might consider making it a boolean (yes/no) field bound to a
checkbox. This would save real estate on your form and would probably
make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options
(Active & Finished)cbStatus, and another combo box that list
clients, is possible to lock The clients Combo Box cbOwnerID when it
is in active mode and unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to
give the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such
as the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion) =
vbYes Then

This will display Yes and No buttons and a question mark icon.
The function will return the value vbYes only if the "Yes" button
was clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to work,
and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
G

Graham Mandeno

But did you add that field to your table first? And is it included in your
record source?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
I got a compile error on Finished , member not found
Thanks..Bob

Graham Mandeno said:
So, your Form_Current event proc is already doing something (i.e. calling
the Sub named "subShowvalues")

No matter - you want it to also do something else, so add your line of
code after that one.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
Graham this is what is in there:
Private Sub Form_Current()
subShowValues
End Sub

Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top
left, or use Ctrl-R). Now, in the properties window, on the Event tab,
scroll down until you see "On Current". Type a left-square-bracket "["
in the cell and "[Event Procedure]" should appear. Then click the
three dots button to the right of the cell. The VBA code window should
open showing (among other things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's
where the code goes.

What I meant about a boolean field was to have a yes/no field in your
table named "Finished". You can then bind this to a checkbox on your
form and a single click will put a tick in the box (Finished) or clear
it (Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but
they have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
No Graham just has the two (Active,Finished), should this be done
another way?.....Regards Bob Vance

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for
cbStatus, AND in the Current event for your form, add the following
code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"? If
not, you might consider making it a boolean (yes/no) field bound to
a checkbox. This would save real estate on your form and would
probably make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options
(Active & Finished)cbStatus, and another combo box that list
clients, is possible to lock The clients Combo Box cbOwnerID when
it is in active mode and unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to
give the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options such
as the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion)
= vbYes Then

This will display Yes and No buttons and a question mark icon.
The function will return the value vbYes only if the "Yes" button
was clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose your
entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to
work, and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 
B

Bob

Sorry Graham I am going to give on this just getting over my head, thanks
for the help....Bob

Graham Mandeno said:
But did you add that field to your table first? And is it included in
your record source?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob said:
I got a compile error on Finished , member not found
Thanks..Bob

Graham Mandeno said:
So, your Form_Current event proc is already doing something (i.e.
calling the Sub named "subShowvalues")

No matter - you want it to also do something else, so add your line of
code after that one.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Graham this is what is in there:
Private Sub Form_Current()
subShowValues
End Sub

Hi Bob

With the form open in design view and the properties window displayed
(View>Properties), select the form (click the grey square in the top
left, or use Ctrl-R). Now, in the properties window, on the Event
tab, scroll down until you see "On Current". Type a
left-square-bracket "[" in the cell and "[Event Procedure]" should
appear. Then click the three dots button to the right of the cell.
The VBA code window should open showing (among other things):

Private Sub Form_Current()
| <<< cursor is here
End Sub

This is the event procedure for your form's Current event. That's
where the code goes.

What I meant about a boolean field was to have a yes/no field in your
table named "Finished". You can then bind this to a checkbox on your
form and a single click will put a tick in the box (Finished) or clear
it (Active).

Your code below would then change to:

cbOwnerID.Locked = Me.Finished

BTW, I know horses are pretty important in your neck of the woods, but
they have clients???
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Could not find this:
AND
in the Current event for your form, add the following code:
Thanx..Bob
No Graham just has the two (Active,Finished), should this be done
another way?.....Regards Bob Vance

Hi Bob

Sorry, I've been away for a few days.

Yes, this is certainly possible. In the AfterUpdate event for
cbStatus, AND in the Current event for your form, add the following
code:

cbOwnerID.Locked = (cbStatus = "Finished")

Does Status have any options other than "Active" and "Finished"?
If not, you might consider making it a boolean (yes/no) field bound
to a checkbox. This would save real estate on your form and would
probably make the user interface more intuitive.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand - Torbay :)

Graham I have a form that has a combo Box that has 2 options
(Active & Finished)cbStatus, and another combo box that list
clients, is possible to lock The clients Combo Box cbOwnerID when
it is in active mode and unlock when in finished mode
Thanks Bob (Papakura)

Thanx Graham got it now!

Hi Bob (fellow Kiwi? :)

The default MsgBox has only one button - "OK". If you want to
give the user a choice you need at least two buttons.

The second argument for MsgBox allows you to specify options
such as the buttons to show and the icon to display.

For example, you could say:

If MsgBox("Does this horse have a Client", vbYesNo + vbQuestion)
= vbYes Then

This will display Yes and No buttons and a question mark icon.
The function will return the value vbYes only if the "Yes"
button was clicked.

As well as vbYesNo, you can use vbOKCancel, vbYesNoCancel, or
vbAbortRetryCancel (the latter two have three buttons).

Also, it is not incorrect, but it is most unusual to enclose
your entire procedure body in an If...EndIf block.

You should change this to:

On Error ...
If MsgBox ... Then
DoCmd.GoToRecord , , acNewRec
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

After the MsgBox line I must be missing something for it to
work, and can I change "Yes" to "Ok"

Private Sub Command98_Click()
If MsgBox("Does this horse have a Client") = vbYes Then
On Error GoTo Err_Command98_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click
End If

End Sub


Thanks in advance.........Bob Vance
 

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

Similar Threads

What is wrong with my code! 6
New sequentiall Number to new record 19
Jet Engine Error Message 2
Access Pop-Up Calendar 2
lock button 15
DLookup 4
Runtime Error "Invalid use of Null" 2
Code to open a query 2

Top