Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Updating records and getting Runtime Error 3075 (https://www.askmehelpdesk.com/showthread.php?t=522514)

  • Nov 3, 2010, 04:44 AM
    reidi_lexi
    Updating records and getting Runtime Error 3075
    Hello there!
    For the access program I am going to do, there is already an existing data. I had imported it from Excel. Now, I have created a URN field from the look up table and wanted to update it to the main table which comprises the existing data. I've used the following code but I keep on getting the Runtime Error 3075 message. Here is my code:

    Private Sub Command0_Click()
    Dim md As Recordset
    Dim phr As Recordset
    Dim entry As Recordset
    Dim phrname As String
    Dim mdname As String

    Set md = CurrentDb.OpenRecordset("tblMDinfo")
    Set phr = CurrentDb.OpenRecordset("tblPHRinfo")
    Set entry = CurrentDb.OpenRecordset("tblEntryTrack")
    phrname = phr("fldPHR")
    mdname = md("fldMDName")

    Do While entry.EOF = False
    CurrentDb.Execute "update tblEntryTrack set [tblEntryTrack].[fldPHRID] = [tblPHRinfo].[fldPHRID] where [tblEntryTrack].[fldPHR] = " & phrname & ";"
    CurrentDb.Execute "update tblEntryTrack set [tblEntryTrack].[fldMDID] = [tblMDinfo].[fldMDID] where [tblEntryTrack].[fldMDName] = " & mdname & ";"
    Loop
    MsgBox "done!"
    End Sub

    Help anyone?
  • Nov 3, 2010, 07:37 AM
    ScottGem

    First what is the full and Exact message you are getting. Second, What data types are fldPHR and fldMDName? Also what info is in them? Define URN field?

    And why do this in code? Why not just run an Update query?

    If I follow what you are doing, you added a Foreign key field to replace name as the FK, which is a good idea. But then all you need is to create an Update query, joined on the old FK and run it. No need for the looping code which has syntax errors.
  • Nov 3, 2010, 10:01 PM
    reidi_lexi
    That did give me an idea... It's okay now. Thanks!!
  • Nov 4, 2010, 03:39 AM
    ScottGem
    Quote:

    Originally Posted by reidi_lexi View Post
    That did give me an idea...It's okay now. Thanks!!!

    Glad to help, how did you solve it?

  • All times are GMT -7. The time now is 02:48 PM.