Changing the code around?

galvinjaf

Registered User.
Local time
Today, 15:41
Joined
Jan 5, 2016
Messages
108
I have a simple form that I have supervisors fill out as they listen to recorded phone calls for telephone operators. They open the form, select their name from a drop down list, fill in the form, and then press a button that saves and closes the form (pic attached). Once they close the form, the information is then saved in datasheet view in the employees information page.

The form they fill out needs to be filled out 5 times per telephone operator since we score them on 5 random phone calls. The form itself needs to be closed and opened 5 times. The code for that 'save and close' button is below. Is there a way to get the form to have 5 different sections that ask the same information, that let's the supervisor open the form one time, fill in all 5 calls and then saves the form to the datasheet view?

Option Compare Database
Option Explicit

Private Sub btCancel_Click()
If Me.Dirty Then RunCommand acCmdUndo
DoCmd.Close
Forms!frmNavigation.Visible = True
End Sub

Private Sub btSaveClose_Click()
RunCommand acCmdSave
DoCmd.Close
Forms!frmNavigation.Visible = True
End Sub
 

Attachments

  • 5 MSG Review.JPG
    5 MSG Review.JPG
    43.7 KB · Views: 78
Yeah, add a button called cmdSaveAndNext, which does just what you think, including incrementing a counter.
 
Thanks for the replies. What part of my code to I change with regards to the following:

const cQuote="""" 'Thats two quotes
me!Control.DefaultValue = cQuote & me!Control.Value & cQuote

^^ I grabbed from your link... but what piece do I change to relate to me form? Also, I liked the idea of the incrementer....that would say 1 of 2, 1 of 3....
 
You'd change "Control" to the name of your textbox.
 
Great, thank you. I'll try that now. Would this also give me some type of counter?

Also, when you say text box, do you mean form?
 
No, I meant textbox. In your picture, it looks like a combo though. In short, the control (not form) containing the data you want carried forward.

The counter was Mark's excellent idea, so I'll let him follow up on that.
 
Got it, I changed the code to reflect my control as 'combo21' which is the name of that combo box, but when I attempt to fill out the form and click on the button I created with the code below, nothing happens?

Private Sub Command30_Click()
Const cQuote = """" 'Thats two quotes
Me!Combo21.DefaultValue = cQuote & Me!Combo21.Value & cQuote
End Sub
 
Add an unbound textbox to the form, maybe call it tbCounter. When the form opens, do . . .
Code:
Private Sub Form_Open(Cancel As Integer)
[COLOR="Green"]   'set the counter to 1[/COLOR]
   me.tbCounter = 1
End Sub
Then, under your cmdSaveAndNext button, do . . .
Code:
Private Sub cmdSaveAndNext_Click()
[COLOR="Green"]   'do this after other operations under this button[/COLOR]
   If Me.tbCounter = 5 Then
[COLOR="Green"]      'close the form, but you could also prompt the user 
      'for the next name to audit
[/COLOR]      DoCmd.Close acForm, Me.Name
   Else
[COLOR="Green"]      'otherwise, add one to the counter[/COLOR]
      Me.tbCounter = Me.tbCounter + 1
   End If
End Sub
 
That alone wouldn't do anything. Personally I'd probably put it in the after update event of the combo. An alternative would be behind this new button, before going to a new record.
 
I'm not sure, but I don't think changes to the default value of a control will show up until you move to a new record. It's at new records where default values are applied.
 
I've played with codes and buttons etc, but seem to come up empty. I get errors when I attempt to change the code and add what you suggest. Below is the code for the form: Any help on creating the code to achieve the counter and cmdsaveandnext button?

Option Compare Database
Option Explicit

Private Sub btCancel_Click()
If Me.Dirty Then RunCommand acCmdUndo
DoCmd.Close
Forms!frmNavigation.Visible = True
End Sub

Private Sub btSaveClose_Click()
RunCommand acCmdSave
DoCmd.Close
Forms!frmNavigation.Visible = True
End Sub

Private Sub Combo21_AfterUpdate()

Const cQuote = """" 'Thats two quotes
Me!Combo21.DefaultValue = cQuote & Me!Combo21.Value & cQuote
End Sub
 
At it's simplest, the new button would use GoToRecord to go to a new record. Look in help for the appropriate arguments, and add Mark's counter bits.
 
. . . but seem to come up empty. I get errors . . .
For specific help, please describe the problems very specifically. Without a clear description of the exact symptoms you've observed, we can only speculate.
 
Okay, so I was able to get the button to go to a new record, and count to 5. But the form is not hanging onto the operators name in the drop down combo box. It's a new record all together. Any ideas? Code below:

Private Sub Command32_Click()
DoCmd.GoToRecord , , acNewRec
Const cQuote = """" 'Thats two quotes
Me!Combo21.DefaultValue = cQuote & Me!Combo21.Value & cQuote

If Me.tbCounter = 5 Then
'close the form, but you could also prompt the user
'for the next name to audit
DoCmd.Close acForm, Me.Name
Else
'otherwise, add one to the counter
Me.tbCounter = Me.tbCounter + 1
End If
End Sub


Private Sub Form_Open(Cancel As Integer)
'set the counter to 1
Me.tbCounter = 1
End Sub
 
I finally had a chance to place the code before going to the new record and it worked great.

Sometimes you stare at this stuff long enough and it throws you for a loop. I thank both of you for your help and am very much appreciative.
 

Users who are viewing this thread

Back
Top Bottom