Ah, I see the problem. DoCmd.Save saves the FORM, not the record. You need DoCmd.RunCommand acSaveRecord.
John Viescas, author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
John,
for kicks and giggles I added a join in the Relationships diagram tool in Access today after the failed attempt.. 1 to many
Yes it is a subform on a form.
frmTasks is the main form
sfrmTaskDetails is the subform
The code behind the button that adds the record
Private Sub cmdTableTransfer_Click()
Rank.Value = "A"
Me.cboTaskType = 10
Me.cboTaskName = "Transfer Copy Process"
TaskTitle.Value = "Table Transfer"
TaskDescription.Value = "Table Transfer and Copy Processes for all Databases"
Me.cboDepartment = 33
DueDate.Value = Date
Me.ColorOfRecord = "vbRed"
CompletedDate.Value = Date
StatusType.Value = "Completed"
DoCmd.Save
Me.sfrmTaskDetails.Form!TaskUpdateDate = Date
Me.sfrmTaskDetails.Form!TimeSpent = 1
Me.sfrmTaskDetails.Form!TaskUpdate = "Used PeopleSoft Datawarehouse Database to transfer all needed tables and to copy into all working Databases. Also Processed the Repurpose Database objects."
Me.sfrmTaskDetails.Form!TaskID = Forms!frmTasks!TaskID
Me.Refresh
DoCmd.Save
cmdOpenqryTodayTasksTimeSpent.SetFocus
End Sub
the link master TaskID
the link Chidl Taskid
Jim Wagner
Jim-
I would need to see any code you have in the form(s) you're using to enter the data. Is this a form with a subform?
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
John,
I added the save command and it did no help.
TaskId is an Autonumber in the tblTasks table
TaskDetailsID is an autonumber in the tblTaskDetails table
TaskID is a number in the tblTaskDetails table.
My frustration is that I can manually add the data for the task and the fields populate correctly. But when I run the procedure, it fails.
Jim Wagner
Thank You John, I added a save command to save the record. I do not want to mess up the sync of the numbers in the parallel databases so I will wait until tomorrow to see if it works. I will let you know.
Jim Wagner
Jim-
If "TaskID" is an "autonumber," that's the problem. When you "dirty" a new row that has an Autonumber in Access, Access immediately sets the next value. When the table is in SQL Server, however, SQL Server doesn't generate the number until after you save the row.
John Viescas, author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Access Applications
Hello all,
I run a parallel Tasks local database and a SQL backend to Access database. On the databases I have a main form and a linked sub form. Every morning I run a process to get outside data into the database. Because I do it every day I have a button that populates fields in the form so I do not have to type them. This button works great on the local database but the SQL backend I am missing the data in the field that the forms are linked on the following below. If I add a new record by typing all of the fields I have no issues. But the populated process seems to miss the linked field. Every day I need to go to the table and add the Task ID from the main table to the table for the subform.
Is this a SQL issue or should I add the Taskid field to the vba process?
the link master TaskID
the link Chidl Taskid
the process
Private Sub cmdTableTransfer_Click()
Rank.Value = "A"
Me.cboTaskType = 10
Me.cboTaskName = "Transfer Copy Process"
TaskTitle.Value = "Table Transfer"
TaskDescription.Value = "Table Transfer and Copy Processes for all Databases"
Me.cboDepartment = 33
DueDate.Value = Date
Me.ColorOfRecord = "vbRed"
CompletedDate.Value = Date
StatusType.Value = "Completed"
Me.sfrmTaskDetails.Form!TaskUpdateDate = Date
Me.sfrmTaskDetails.Form!TimeSpent = 1
Me.sfrmTaskDetails.Form!TaskUpdate = "Used PeopleSoft Datawarehouse Database to transfer all needed tables and to copy into all working Databases. Also Processed the Repurpose Database objects."
Me.Refresh
cmdOpenqryTodayTasksTimeSpent.SetFocus
End Sub
Thank You for any advice. I am trying to learn SQL by creating the SQL backend scenario.
Jim Wagner
Tidak ada komentar:
Posting Komentar