I'll cut to the chase:
I'm writing a program written in Access Module. I never wrote in VBA code before although I do have programming experience. The idea is broken down into 3 steps.
Step 1:
Have a table that contains the Main Job Position that need to be filled and a table with the list of Employees.
Compare the "Main Position" of the Employee with the "Main Position" that needs to be filled.
If it’s a match, copy Employee record into "New Schedule" table and if not copy Job Position into "Job Position Not Yet Filled" table.
I could go on but I'm not even past this part yet which is the most important.
It’s very simple yet frustrating to know that the idea is in my head but I'm having a great amount of difficulties putting it on paper.
Below is the code that I have so far. What I'm trying to do is to be able to copy records (individually or with an array) from one table into another. I have done extensive research as you may be able to tell by the commented code. You guys are my last hope!
I'm writing a program written in Access Module. I never wrote in VBA code before although I do have programming experience. The idea is broken down into 3 steps.
Step 1:
Have a table that contains the Main Job Position that need to be filled and a table with the list of Employees.
Compare the "Main Position" of the Employee with the "Main Position" that needs to be filled.
If it’s a match, copy Employee record into "New Schedule" table and if not copy Job Position into "Job Position Not Yet Filled" table.
I could go on but I'm not even past this part yet which is the most important.
It’s very simple yet frustrating to know that the idea is in my head but I'm having a great amount of difficulties putting it on paper.
Below is the code that I have so far. What I'm trying to do is to be able to copy records (individually or with an array) from one table into another. I have done extensive research as you may be able to tell by the commented code. You guys are my last hope!
Just like VBA, I am completly new to this and I thank you GREATLY in advance.
Code:
Option Compare Database Public Function Fill_Job_Positions() 'On Local Error GoTo Fill_Job_Positions_Err '-------------------------Summary-------------------------------- ' 'Step 1: ' ' Sets "dbs" as current Database of type "Data Acess Object" ' ' Opens and Runs a Query that Makes a Table that may already exist. ' Click "Yes" to delete existing table and paste to remake Table. ' ' Opens a new recordset within the table "New Schedule" ' For later usag3 ' ' Opens a new recordset within the table "Jobs Not Yet Filled" ' For later usage ' '-------------------------Summary-------------------------------- Dim dbs As DAO.Database Set dbs = CurrentDb DoCmd.OpenQuery "Make Jobs To Fill Query", acViewNormal, acReadOnly Dim Jobs As DAO.Recordset Set Jobs = dbs.OpenRecordset("Jobs To Fill") Dim Employees As DAO.Recordset Set Employees = dbs.OpenRecordset("Put It") Dim Schedule As DAO.Recordset Set Schedule = dbs.OpenRecordset("New Schedule") Dim NotFilled As DAO.Recordset Set NotFilled = dbs.OpenRecordset("Jobs Not Yet Filled") '-------------------------Summary-------------------------------- ' 'Step 2: ' ' Sets "dbs" as current Database of type "Data Acess Object" ' ' Opens and Runs a Query that Makes a Table that may already exist. ' Click "Yes" to delete existing table and paste to remake Table. ' ' Creates a new table and names it "New Schedule" ' For later usage ' '-------------------------Summary-------------------------------- 'Testing the extraction method (fields from one table into another) 'Test ~ Copying Jobs (DAO) into NotFilled (DAO) 'Declare the strings needed to individually extract data Dim FirstName As String Dim LastName As String Dim strMP As String Dim RP As String Jobs.MoveFirst strMP = Jobs NotFilled.MoveFirst NotFilled.AddNew NotFilled![me] = MP NotFilled.Update '-------------------------Summary-------------------------------- ' 'Code to read records from a source into an array (Works) ' 'Dim varRec As Variant 'Dim intNumRet As Integer 'Dim intNumCol As Integer 'Dim varRec2 As Variant 'varRec = Jobs.GetRows(3) 'intNumRet = UBound(varRec, 2) + 1 'intNumCol = UBound(varRec, 1) + 1 'varRec2 = NotFilled.GetRows(3) 'intNumRet = UBound(varRec2, 2) + 1 'intNumCol = UBound(varRec2, 1) + 1 'Dim intRow As Integer 'Dim intCol As Integer 'For intRow = 0 To intNumRet - 1 ' For intCol = 0 To intNumCol - 1 ' Debug.Print varRec(intCol, intRow) ' Next intCol 'Next intRow 'Jobs.Close ' '-------------------------Summary-------------------------------- End Function
Comment