Change check box value before going to new record

  • Thread starter cableguy47905 via AccessMonster.com
  • Start date
C

cableguy47905 via AccessMonster.com

I have a form that when I click on the cmd button, the form will open up a
new record with one field [Ref_ID] has the default value of the [Call_ID] of
the form that I was just previously on. The form is an addition only form
and I would like it to update a checkbox automatically when I click that cmd
button to open the new record.

It is basically a way of being able to create a new record that refers to
that current record.
Can anyone help?

Thanks in advance,
Lee
 
T

TonyT

You can use the *new* forms On_load event to check the calling form and then
set the checkbox value eg; me.chkMyCheckbox = -1

TonyT..
 
C

cableguy47905 via AccessMonster.com

I guess what I meant to say was that the cmd button will "goto" a new record
Using the "record operation" in the cmd button wizard. It will open the
record with the default values of one of the fields of the new record equal
to the primary key of the original record. Upon leaving that record, I would
like to make one last change and set chkContinued = -1. This is not for all
new records, just the ones that are opening via this cmd button. I am using
the same form, just going to a new record. Unless I am using your suggestion
wrong, it makes the chkContinued = -1 for all new records. This checkbox
should only be checked when the user wants to make a "followup" record. A
record that is referring to this record. If there are no "followup" records,
then chkContinued should not be checked.
I hope I that explains the idea a little better.
You can use the *new* forms On_load event to check the calling form and then
set the checkbox value eg; me.chkMyCheckbox = -1

TonyT..
I have a form that when I click on the cmd button, the form will open up a
new record with one field [Ref_ID] has the default value of the [Call_ID] of
[quoted text clipped - 8 lines]
Thanks in advance,
Lee
 
T

TonyT

If you get the cmdbutton to sat a public variable to a given value on
pressing it, you can then use;
If sglmyVariable = -7 then
me.chkmyCheckBox = -1
else me.chkmyCheckBox = 0
End if

But make sure you set this variable to another value after using it here and
also on closing the other form, otherwise the check for -7 will be still true
when going into the same form from another route!

TonyT..

cableguy47905 via AccessMonster.com said:
I guess what I meant to say was that the cmd button will "goto" a new record
Using the "record operation" in the cmd button wizard. It will open the
record with the default values of one of the fields of the new record equal
to the primary key of the original record. Upon leaving that record, I would
like to make one last change and set chkContinued = -1. This is not for all
new records, just the ones that are opening via this cmd button. I am using
the same form, just going to a new record. Unless I am using your suggestion
wrong, it makes the chkContinued = -1 for all new records. This checkbox
should only be checked when the user wants to make a "followup" record. A
record that is referring to this record. If there are no "followup" records,
then chkContinued should not be checked.
I hope I that explains the idea a little better.
You can use the *new* forms On_load event to check the calling form and then
set the checkbox value eg; me.chkMyCheckbox = -1

TonyT..
I have a form that when I click on the cmd button, the form will open up a
new record with one field [Ref_ID] has the default value of the [Call_ID] of
[quoted text clipped - 8 lines]
Thanks in advance,
Lee
 
C

cableguy47905 via AccessMonster.com

I am not sure when I should reset the variable to another value so that it
does not affect the records that should have the chk box checked.
If you get the cmdbutton to sat a public variable to a given value on
pressing it, you can then use;
If sglmyVariable = -7 then
me.chkmyCheckBox = -1
else me.chkmyCheckBox = 0
End if

But make sure you set this variable to another value after using it here and
also on closing the other form, otherwise the check for -7 will be still true
when going into the same form from another route!

TonyT..
I guess what I meant to say was that the cmd button will "goto" a new record
Using the "record operation" in the cmd button wizard. It will open the
[quoted text clipped - 19 lines]
 
C

cableguy47905 via AccessMonster.com

Actually, I thought I understood the idea behind setting the variable, but I
get a type mismatch. Here is the code for that btn.

Private Sub btnFollowUpRec_Click()
On Error GoTo Err_btnFollowUpRec_Click

Const cQuote = """" 'Thats two quotes

Me!Ref_ID.DefaultValue = Me!Call_ID.Value
Me!Product_ID.DefaultValue = Me!Product_ID.Value

DoCmd.GoToRecord , , acNewRec


Exit_btnFollowUpRec_Click:
Exit Sub

Err_btnFollowUpRec_Click:
MsgBox Err.Description
Resume Exit_btnFollowUpRec_Click

End Sub

This is what I have for the form OnOpen:

Private Sub Form_Open(Cancel As Integer)
Outlook_Appt.Visible = False
Open_Call_Back.Visible = False

If chkContinued = -1 Then
chkContinued.Visible = True
Else
chkContinued.Visible = False
End If
If Call_Back = -1 Then
Open_Call_Back.Visible = True
Else
Open_Call_Back.Visible = False
End If

Notes.Visible = True
CB_Number.Visible = False
Client_Email.Visible = False
Subject.Visible = False
CB_Notes.Visible = False
CB_Date.Visible = False
CB_Time.Visible = False
Appt_Length.Visible = False
Send_Reminder.Visible = False
Today.Visible = False
End Sub

Thanks for the help

I am not sure when I should reset the variable to another value so that it
does not affect the records that should have the chk box checked.
If you get the cmdbutton to sat a public variable to a given value on
pressing it, you can then use;
[quoted text clipped - 14 lines]
 
T

TonyT

what code are you using for the variable? i don't see it.

TonyT..

cableguy47905 via AccessMonster.com said:
Actually, I thought I understood the idea behind setting the variable, but I
get a type mismatch. Here is the code for that btn.

Private Sub btnFollowUpRec_Click()
On Error GoTo Err_btnFollowUpRec_Click

Const cQuote = """" 'Thats two quotes

Me!Ref_ID.DefaultValue = Me!Call_ID.Value
Me!Product_ID.DefaultValue = Me!Product_ID.Value

DoCmd.GoToRecord , , acNewRec


Exit_btnFollowUpRec_Click:
Exit Sub

Err_btnFollowUpRec_Click:
MsgBox Err.Description
Resume Exit_btnFollowUpRec_Click

End Sub

This is what I have for the form OnOpen:

Private Sub Form_Open(Cancel As Integer)
Outlook_Appt.Visible = False
Open_Call_Back.Visible = False

If chkContinued = -1 Then
chkContinued.Visible = True
Else
chkContinued.Visible = False
End If
If Call_Back = -1 Then
Open_Call_Back.Visible = True
Else
Open_Call_Back.Visible = False
End If

Notes.Visible = True
CB_Number.Visible = False
Client_Email.Visible = False
Subject.Visible = False
CB_Notes.Visible = False
CB_Date.Visible = False
CB_Time.Visible = False
Appt_Length.Visible = False
Send_Reminder.Visible = False
Today.Visible = False
End Sub

Thanks for the help

I am not sure when I should reset the variable to another value so that it
does not affect the records that should have the chk box checked.
If you get the cmdbutton to sat a public variable to a given value on
pressing it, you can then use;
[quoted text clipped - 14 lines]
Thanks in advance,
Lee
 
C

cableguy47905 via AccessMonster.com

Nope, as it is, this does not work for me. I don't know where to put the
code for the variable.
what code are you using for the variable? i don't see it.

TonyT..
Actually, I thought I understood the idea behind setting the variable, but I
get a type mismatch. Here is the code for that btn.
[quoted text clipped - 58 lines]
 
C

cableguy47905 via AccessMonster.com

I have gone a slightly different route, but I am getting "Unable to go to
specified record" as an error. Obviously not doing something right, but I am
just tossing around ideas. Can I still take this route?

Private Sub btnFollowUpRec_Click()
On Error GoTo Err_btnFollowUpRec_Click


Me!Ref_ID.DefaultValue = Me!Call_ID.Value
Me!Product_ID.DefaultValue = Me!Product_ID.Value
Me!chkContinued.Visible = True
Me!chkContinued.Value = -1
Me!chkContinued.DefaultValue = 0

DoCmd.GoToRecord , , acNewRec


Exit_btnFollowUpRec_Click:
Exit Sub

Err_btnFollowUpRec_Click:
MsgBox Err.Description
Resume Exit_btnFollowUpRec_Click

End Sub
Nope, as it is, this does not work for me. I don't know where to put the
code for the variable.
what code are you using for the variable? i don't see it.
[quoted text clipped - 5 lines]
 
C

cableguy47905 via AccessMonster.com

I have checked many (about 30) of the recent postings regarding "Can't go to
specified record", but I still haven't figured it out.

The form is set to only allow additions, not edits, it is set for Dynaset
recordset type. If I take out the:
Me!chkContinued.Value = -1
Me!chkContinued.DefaultValue = 0

Then I am able to add a record, but I am not able to make the change to
chkContinued in the current record.

Any other ideas?

I have gone a slightly different route, but I am getting "Unable to go to
specified record" as an error. Obviously not doing something right, but I am
just tossing around ideas. Can I still take this route?

Private Sub btnFollowUpRec_Click()
On Error GoTo Err_btnFollowUpRec_Click


Me!Ref_ID.DefaultValue = Me!Call_ID.Value
Me!Product_ID.DefaultValue = Me!Product_ID.Value
Me!chkContinued.Visible = True
Me!chkContinued.Value = -1
Me!chkContinued.DefaultValue = 0

DoCmd.GoToRecord , , acNewRec


Exit_btnFollowUpRec_Click:
Exit Sub

Err_btnFollowUpRec_Click:
MsgBox Err.Description
Resume Exit_btnFollowUpRec_Click

End Sub
Nope, as it is, this does not work for me. I don't know where to put the
code for the variable.
[quoted text clipped - 4 lines]
 
C

cableguy47905 via AccessMonster.com

I got it. I simply needed to make sure the focus was placed on a field
before adding the new record. It works now.
Thanks for all the suggestions.
I have checked many (about 30) of the recent postings regarding "Can't go to
specified record", but I still haven't figured it out.

The form is set to only allow additions, not edits, it is set for Dynaset
recordset type. If I take out the:
Me!chkContinued.Value = -1
Me!chkContinued.DefaultValue = 0

Then I am able to add a record, but I am not able to make the change to
chkContinued in the current record.

Any other ideas?
I have gone a slightly different route, but I am getting "Unable to go to
specified record" as an error. Obviously not doing something right, but I am
[quoted text clipped - 27 lines]
 

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