Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

Auto Fill in Continuous Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Balfour211 - 20 Jan 2008 22:06 GMT
I am using Access 2003

I have a subform that lists employees by  name.  The data source for that
subform is from an "Index" table that lists all employees.  There are usually
a total of at least 14 employees in the Index, and every day a new entry is
started with this form having to list all 14 employees.  Right now, instead
of going down the list and entering each of the 14 employees, I hard code the
filling in of the list with a "Value" (Employee = "Smith").  

   DoCmd.GoToRecord , , acNext
   Employee= "Smith"
   DoCmd.GoToRecord , , acNext
   Employee= "Jones"
   DoCmd.GoToRecord , , acPrevious, 1
   Status.SetFocus

The "acPrevious" command takes me back to the first entry.  If I had 14
names, the value would be 13.  

The problem with this is that I have to put the Employees name in the code.  
This makes the changing of employees a "recoding task" instead of just
changing the Index table.

Question:  Is there a way to have each of the names listed in the Index
table automatically fill in the employee fields of the continuous form?  If I
could hit a command button, I would end up with 14 rows with the Employee
field filled in with the names out of the Employee Index table.  Just for
clarification, there is another field on this form that goes with the
Employee's name.  That other filed is "Status".

Thanks in advance,
Balfour211
Tom Wickerath - 20 Jan 2008 22:39 GMT
You should be able to run an append query in VBA code to achieve this result.
Here is an example from a database of mine. You'll need to change the field
and table names for your database:

Private Sub cmdAddProjSchedRecords_Click()
On Error GoTo ProcError

'This procedure inserts a cartesian product set of records into
tblChgReqSchedItems
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb()

'First, save the parent record, if it is dirty. Set focus back to this
subform, since the
'Form_Current event procedure that fires when the record is saved sets focus
to the "pgeGeneral" page.
If Me.Dirty = True Then
  Me.Dirty = False
  Me.TabOnDemand.Pages("pgeProjectSchedule").SetFocus
End If

'Create insert statement to insert records into tblChgReqSchedItems
strSQL = "INSERT INTO tblChgReqSchedItems ( fkChangeRequest, fkProjSchedID )
" _
      & "SELECT Chng_rqst.pkChangeRequest, tblChgReqSched.pkProjSchedID " _
      & "FROM Chng_rqst, tblChgReqSched " _
      & "WHERE Chng_rqst.pkChangeRequest= " & Me.Request_rk & " AND
tblChgReqSched.blnActiveSchdItem = -1;"

  db.Execute strSQL  'Note: We do not want to include the optional
dbFailOnError parameter. If you do, a user
                      '      could not add a record back in, unless all
records were first deleted.
 
'Requery subform
Me.ProjectScheduleContainer.[Form].Requery
Me.txtHidden.SetFocus
Me.cmdAddProjSchedRecords.Enabled = False
Me.txtSummaryTotalHours.Visible = True

ExitProc:
  'Cleanup
  On Error Resume Next
  Set db = Nothing
  Exit Sub
ProcError:
  Select Case Err.Number
     Case 2101 'Ignore this error
     Case 3022 'Duplicates
        MsgBox "You cannot add these records again.", _
               vbCritical, "Attempt To Add Duplicate Records Detected..."
        Me.txtHidden.SetFocus
        Me.cmdAddProjSchedRecords.Enabled = False
     Case Else
        MsgBox "Error " & Err.Number & ": " & Err.Description, _
               vbCritical, "Error in cmdAddProjSchedRecords_Click event
procedure..."
  End Select
  Resume ExitProc
End Sub

Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

> I am using Access 2003
>
[quoted text clipped - 28 lines]
> Thanks in advance,
> Balfour211
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.