Asterisk on Record Selector

  • Thread starter Thread starter Ralph
  • Start date Start date
R

Ralph

I've written code to open a form, transfer values, then
close the form. The code works once. On 2nd (and
subsequent times) my values (on the form) are deleted
(after they have been transfered correctly)(like hitting
Esc) and an ASTERISK is in the record selector. I give up!
Thanks for any suggestions!
Ralph
 
Hello Ralph

Could you post the code that you have wrote as this may be the cause of your
problem?

Neil.
 
I've written code to open a form, transfer values, then
close the form. The code works once. On 2nd (and
subsequent times) my values (on the form) are deleted
(after they have been transfered correctly)(like hitting
Esc) and an ASTERISK is in the record selector. I give up!
Thanks for any suggestions!
Ralph

Well, it would seem there's something wrong with the code; care to
post it so we can have a chance at seeing what that might be?
 
-----Original Message-----
I've written code to open a form, transfer values, then
close the form. The code works once. On 2nd (and
subsequent times) my values (on the form) are deleted
(after they have been transfered correctly)(like hitting
Esc) and an ASTERISK is in the record selector. I give up!
Thanks for any suggestions!
Ralph
.
Here's the code. If you are confused by the code at the
bottom; it is to remove the choices made on the listbox
(rowsource=" ", then re-populate (rowsource = SELECT...)
the values. This code has worked perfectly in an app I
wrote years ago (and is used daily by teachers). Thanks
for your help! Ralph

Private Sub cmdMultiAttendance_Click()
Dim intVar As Integer
Dim intPosition As Integer
Dim intNum As Integer
Dim strBuffer As Integer
Dim strRecipe As String
'Count # of selected items
intNum = Me!lstStudents.ItemsSelected.Count
'loop thru # of counts; 0 is first position!
For intVar = 0 To (intNum - 1)
'Get position of first,second,ect selection
intPosition = lstStudents.ItemsSelected(intVar)
'Get data from from above position
strBuffer = Me.lstStudents.ItemData(intPosition)

'Open frmMultiAttendence, transfer values
DoCmd.OpenForm "frmMainAttendance", , , , acFormAdd 'Opens
to new record
'Transfer StudentID from listbox
Forms!frmMainAttendance!txtStudentID = strBuffer
'Transfer Date of Absence
Forms!frmMainAttendance!txtDateOfAbsence =
Me.txtDateOfAbsence
'Transfer Reason for Absence
Forms!frmMainAttendance!txtReasonForAbsence =
Me.cboReasonForAbsence
'Transfer BehaviorPlan
Forms!frmMainAttendance!txtBehaviorPlan =
Me.cboBehaviorPlan
'Transfer Tardy
Forms!frmMainAttendance!ckTardy = Me.ckTardy
'Transfer Unexecused Absence
Forms!frmMainAttendance!ckUnexecused = Me.ckUnexecused
'close form after record is added
DoCmd.Close acForm, "frmMainAttendance"

Next intVar

'Blank out Listbox after adding exercises
Me.lstStudents.RowSource = " "
'restore row source
Me.lstStudents.RowSource = "SELECT NewStudentTable.ID,
NewStudentTable.[First Name], NewStudentTable.[Last Name],
NewStudentTable.GroupID FROM NewStudentTable WHERE
(((NewStudentTable.GroupID)=[Forms]![frmGroupMultiSelect]!
[lstGroups]));"

'Blank out attendance choices

Me.cboBehaviorPlan = " "
Me.cboReasonForAbsence = " "
Me.ckTardy = 0
Me.ckUnexecused = 0

End Sub
 
Your OpenForm command specifies acFormAdd. This specifically tells
Access to open the form in Data Entry mode - conceal all existing
records, and display the new *> record.

I'd suggest instead passing the values to be inserted in the form as a
delimited string in the OpenArgs argument of the form, and parse them
out into form controls in the Open event of the form; and open the
form in Dialog mode. This will stop the execution of your code until
the form is closed or hidden.
 
Back
Top