Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    jeoku, Please answer, Are the tables in your query empty of data?



    Dale

  2. #17
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    The table has data. The query may or may not be empty based on what records I need to add/edit.

  3. #18
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Thank you.
    What criteria do you have for the query?


    Dale

  4. #19
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    Criteria: [Forms]![Project Screen]![PT]

    Basically finds a specified project. There is a previous form where you search for a specific project.

  5. #20
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Thank you.
    Now what is the problem and what would you like to do?

    Dale

  6. #21
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    Pretty minor now, I have some SQL code so that when I open the form it will check to see if there are any records. If there is not it will add a new record with the Project Title and everything else blank. The problem is that the first time I click the button to open the form the record is created, but the form is not opened. The next time I press the button it is opened as normally. I would like to edit it so that I do not have to click the button twice.

  7. #22
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    If we are talking about the same query. It will always open empty.
    If the query we have been discussing is the underlying query for the form your are trying to open there can be no data in it because of the filter criteria you have in the query that refers the the form you are trying to open.

    Have I missed something? are we still talking about the same query and form?

    Dale

  8. #23
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    Correct. This code checks if there are no new records and then creates a new record if there is none. As I said though I have to open up the form twice. The first time the record will be created and the second time the form will actually open. I am hoping for a way to do this all in one step, but if there isn't a forseen easy way I could live with that.

    Private Sub Form_Open(Cancel As Integer)
    If Me.RecordsetClone.RecordCount = 0 Then
    Cancel = True
    Dim dbs As Database
    Set dbs = CurrentDb
    dbs.Execute "INSERT INTO [Submittals] ([Project Title]) VALUES " & "('" & Forms![Project Screen]![PT] & "');"
    dbs.Close
    End If

  9. #24
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    If Me.RecordsetClone.RecordCount = 0
    This will always return a false, 0 null, empty.
    You are asking for a clone of the dataset of your form. The form is empty. Therefore the recordset is empty. and always will be with the criteria you have in your query.

    IF you are getting the data for your form from this query, and the query is empty, where will you get the PT data from?

    Dale

  10. #25
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    Forms![Project Screen]![PT]

    This data is being pulled from the previous form. The Form "Project Screen" opens up the form "Submittals" which is the one in question.

  11. #26
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    OK, I think I am getting a clearer picture. My mistake.
    You have form Project Screen opened. You selected PT from this form.

    Can you upload your data base.

    I am not sure I can keep this all straight.

    Dale

  12. #27
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    This might make it even more confusing, but I attached it lol. The forms in question is "Project Screen" and "Submittals." There are so many dang reports, tables, queries, and forms in this database that you might get lost quickly.
    Attached Files Attached Files

  13. #28
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Likely looks like mine. Not a problem.

    No body's database looks good when in development.

    Give me a little while. May be tomorrow.

    Dale

  14. #29
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Looked your database over.
    It has a few problems that are beyond my abilities to repair.

    Possibly one of the more experienced members can take a look.


    Dale

  15. #30
    jeoku is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2013
    Posts
    20
    Agreed that it has some problems. Thanks for looking it over at least. It is going to be a work in progress to find issues and fix them. I have never really worked with access before this point so I am applying new tricks to my database as I learn them.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-06-2013, 07:23 PM
  2. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  3. Replies: 3
    Last Post: 08-26-2012, 10:04 PM
  4. Use VBA to edit record or create new record in a query
    By ryantam626 in forum Programming
    Replies: 11
    Last Post: 08-09-2012, 02:37 AM
  5. Replies: 3
    Last Post: 02-28-2012, 12:12 AM

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