09. juni 2003 - 19:46Der er
25 kommentarer og 1 løsning
Problem med ADP
Hej Eksperter,
jeg har et problem med access frontend op mod MS SQL server.
Når jeg indtaster data i min formular eksekveres følgende kode(Eksempel): Private Sub Ftid_AfterUpdate() On Error GoTo err_Ftid_AfterUpdate DoCmd.RunCommand acCmdSaveRecord Call gem_Bdata(BrugerLogin, Desktop, Bnr) 'Modul Gemmer exit_Ftid_AfterUpdate: Exit Sub err_Ftid_AfterUpdate: Call Report_Error(BrugerLogin, Desktop) Resume exit_Ftid_AfterUpdate End Sub ***************** Function gem_Bdata(BrugerLogin, Desktop, Bnr) On Error GoTo err_Bdata Dim Conn As ADODB.Connection Set Conn = CurrentProject.Connection Conn.Execute "exec sp_update_user '" & BrugerLogin & "','" & Desktop & "'," & Bnr Set Conn = Nothing exit_Bdata: Exit Function err_Bdata: Call Report_Error(BrugerLogin, Desktop) 'Modul error Resume exit_Bdata End Function
Problemet er, at når jeg vil taste en værdi ind i det næste felt får jeg en skrivekonflikt!!! Hvordan kan jeg løse dette ??? /DM013
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
skal lige nævnes at jeg har prøvet at placere: DoCmd.RunCommand acCmdSaveRecord, mange forskellige steder i et forsøg på at løse dette, også flere gange i det samme modul
on the fields_afterupdate i now do nothing, and on form_afterupdate execute this: DoCmd.RunCommand acCmdSaveRecord Call gem_Bdata(BrugerLogin, Desktop, Bnr) 'Modul Gemmer DoCmd.RunCommand acCmdSaveRecord ** But i still get the write conflict error !! Function gem_Bdata(BrugerLogin, Desktop, Bnr) On Error GoTo err_Bdata MsgBox "klar" Dim Conn As ADODB.Connection Set Conn = CurrentProject.Connection Conn.Execute "exec sp_update_user '" & BrugerLogin & "','" & Desktop & "'," & Bnr MsgBox "done" Set Conn = Nothing exit_Bdata: Exit Function err_Bdata: Call Report_Error(BrugerLogin, Desktop) 'Modul error Resume exit_Bdata End Function
Not easy when I cant see exactly what your doing! The form should have one "unique" table and thsi data will get written to the dB automatically. If you want to update some other tables you can do this through an SP, but if your trying to update the same record at the same time through an SP then you wil more than likely get problems. Or is it another table?
if it is the same table then you can change these fields in the forms BEFORE update event! The record is not yet written to the dB so you can alter other fields jsut before it does get written. example: If you have a field in the table named BrugerLogin
Even so, you should be able to update it with an SP EFTER the record is written to the dB, but then your form is out of sync with the dB! The correct way in my opinion is to do it at the same time as the form gets written and that is by placing values in these fields in the forms BEFORE update event!
I would have to agrre with Terry (who wouldn't :-) ) - why do something more difficult than needed. Personaly I do something that looks like what you are trying to do by putting some hidden textboxes on my form and then put some code like the following on the BeforeUpdate event of the form.
Private Sub Form_BeforeUpdate If Me.Dirty Then Me!txtUser = "Hans Thorsen" End If End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.