Results 1 to 4 of 4
  1. #1
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41

    Form Zero Length Problem When Duplicating New Record

    Hi, I have this code that duplicates my reccord.


    Code:
    Private Sub btnDuplicateRecord_Click()
    Dim dbs As DAO.Database, Rst As DAO.Recordset
    Dim F As Form
    
    
    ' Return Database variable pointing to current database.
    Set dbs = CurrentDb
    Set Rst = Me.RecordsetClone
    
    
        On Error GoTo Errhandler
    
    
    ' Tag property to be used later by the append query.
    Me.Tag = Me![ID]
    
    
    ' Add new record to end of Recordset object.
    With Rst
       .AddNew
          !Priorities = Me!Priorities
          !Followup = Me!Followup
          !Client = Me!Client
          !BranchInfo = Me!BranchInfo
          !Company_Name = Me!CompanyInfo_ID
          !Contact_Person = Me!ContactPerson
          !Position = Me!PositionInfo_ID
          !Status = Me!Status
          !Telephone = Me!Telephone
          !Fax = Me!Fax
          !Website = Me!Website
          !Category = Me!CatergoryInfo_ID
          !City = Me!City
          !Zipcode = Me!Zipcode
          !Address = Me!Address
          !Country = Me!CountryInfo_ID
       .Update                     ' Save changes.
       .Move 0, .LastModified
    End With
    Me.Bookmark = Rst.Bookmark
    
    
    'Requery the subform to display the newly appended records.
    Forms!frmMain.Form.Requery
    
    
        Exit Sub
    Errhandler:
        TSCs_ReportUnexpectedError "btnDuplicateRecord_Click", Me.Name, "Crash Reporter"
        Resume Next
    Some of the record that I add using the ms access, when i try to duplicate has no errors, but i think this record is from excel that i just imported to my ms access is giving me error about zero length.

    Or if you have a workaround like if the field is null it will skip that field.

    I received this ERROR

    Error 3315 has occured in procedure [btnDuplicateRecord_Click] in module [frmUpdate]
    Field 'Master_FILE.Position' cannot be a zero-length string.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can test before including:

    Code:
    If Len(Me!PositionInfo_ID & vbNullString) > 0 Then
      !Position = Me!PositionInfo_ID
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41
    Wow, why i didn't think of this. thanks.

    Quote Originally Posted by pbaldy View Post
    You can test before including:

    Code:
    If Len(Me!PositionInfo_ID & vbNullString) > 0 Then
      !Position = Me!PositionInfo_ID
    End If

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Duplicating part of a record from a form
    By swenger in forum Programming
    Replies: 15
    Last Post: 07-12-2016, 08:05 AM
  2. Replies: 18
    Last Post: 02-22-2016, 02:51 AM
  3. Replies: 19
    Last Post: 05-13-2013, 01:26 AM
  4. Replies: 4
    Last Post: 02-13-2013, 10:46 AM
  5. subreport length problem
    By stephenaa5 in forum Reports
    Replies: 4
    Last Post: 09-17-2012, 10:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums