Results 1 to 3 of 3
  1. #1
    Buddy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    3

    Question Open Popup in add or edit modes

    I have an Access 2010 DB where there is a 1:many relationship between two tables. 1:many is not the problem. 1 to 0 is the most common, to the extent that we do not want to see the nought side unless data is requested by the user clicking a button. A subform is not suitable. We want the user to see a popup if he requests it by clicking a button. If there is data the popup must display the record in edit mode, if there is no data the popup must accept a new record. That is causing the problem.
    I have not worked with access for at least ten years, the data base has changed - and I am on a steep learning curve. I tried to do it with macros using a on error statement to catch a no data error, but it did not recognize the error. The record ID will always be on the main form.
    Any suggestions will be appreciated, examples would be wonderful.


    Buddy

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    In a 1 to Many relationship, why would you expect only 1 record on the many side?

    If there is data the popup must display the record in edit mode
    Why couldn't there be 2 , 4, 9 records? Which one did you want to open for edit?

    More specifics please.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    In the popup form's load event you might try something like ...

    Code:
    Dim lngRecordCount As Long
    Dim rs As DAO.Recordset
    Dim strFormName As String
    
    Set rs = Me.RecordsetClone
    lngRecordCount = rs.RecordCount
    strFormName = Me.Name
    
        If lngRecordCount < 1 Then
            Set rs = Nothing
            DoCmd.Close acForm, strFormName
            DoCmd.OpenForm strFormName, , , , acFormAdd, acDialog
        Else
            rs.Close
            Set rs = Nothing
        End If

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

Similar Threads

  1. Replies: 5
    Last Post: 12-25-2019, 10:28 PM
  2. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  3. Popup on open
    By imintrouble in forum Forms
    Replies: 2
    Last Post: 09-30-2011, 03:20 PM
  4. Replies: 2
    Last Post: 07-21-2011, 08:57 AM
  5. open small popup form by press functional key
    By alex_raju in forum Access
    Replies: 0
    Last Post: 07-13-2011, 09:20 AM

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