+ Reply to Thread
Results 1 to 14 of 14

Cannot alter query data

  1. #1
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Cannot alter query data

    Sounds complicated, but I don't think it should be. Maybe I'm wrong...

    I have a sub (continueous) form that takes the office number from the main form to look up the names of employees that use that office. For instance, if I select office 4028, the sub form will list off
    Jason
    Jenny
    This data is pulled from a query that checks for "like OfficeNumber" and compares it to the staff list.

    in the details of the form I want to put a button called remove so that if the person is no longer sharing that office, then they can be removed with a button click. The problem I am having is that I cannot alter the records in this specific query. I have another query that does a look up and lists only those names that have an extension assigned to them, and in that query I can alter the data. What restricts when you can do this?

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Cannot alter query data

    Can you please attach a sample of your workbook?

    Thanks!

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    if your query does not contain any way of identifying a specific record then it won't be updateable
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    I'm not going to say that I am any type of wiz at Access. I kind of get what you are talking about, but isn't a look up based on a specific value identifying a specific record?

    Well I kind of got around it. I took the query that was working, cleaned it up to match what I was looking for (same Like code) and that one works. Not sure what I did to the other one, but I can live with that for now. So in the sub form I can now make changes. Thing is I want to make a button that when click sets the officenumber to 0. I've looked this up and found the VB code for this to be something like this:
    Private Sub RemoveName_Click()
    Me.OfficeNumber.Value = 0
    End Sub
    but this doesn't seem to be working. I am not trying to delete the record, I want to set the officenumber to 0 so it is no longer seen in the look up. Again, I can go into the field and change it in the form, and that works. I would just prefer that it be a one click for the operators of this database.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    Quote Originally Posted by jik_ff View Post
    I'm not going to say that I am any type of wiz at Access. I kind of get what you are talking about, but isn't a look up based on a specific value identifying a specific record?
    not necessarily - it could return multiple records or data from several tables.
    Well I kind of got around it. I took the query that was working, cleaned it up to match what I was looking for (same Like code) and that one works. Not sure what I did to the other one, but I can live with that for now. So in the sub form I can now make changes. Thing is I want to make a button that when click sets the officenumber to 0. I've looked this up and found the VB code for this to be something like this:
    Private Sub RemoveName_Click()
    Me.OfficeNumber.Value = 0
    End Sub
    but this doesn't seem to be working. I am not trying to delete the record, I want to set the officenumber to 0 so it is no longer seen in the look up. Again, I can go into the field and change it in the form, and that works. I would just prefer that it be a one click for the operators of this database.
    "doesn't seem to be working" doesn't really tell us a lot. does it cause an error, or do nothing, or do the wrong thing?

  6. #6
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    Well with my query, it only checks one table for it's data. The form is what takes a value from another table to use as the lookup. Again, I had all the same fields in both queries. I must have set something to cause that issue...

    Sorry, nothing happens. I know that it may not refresh the data on the screen. I did 2 things to test this. First I changed the number by editing the field in the form. I closed the form then re-opened it and the change was apparent (the test record was not listed). I then reset the test record, closed all and ran the form again. I then tried pressing the button (a few times just in case). I close the form and re-opened it (as I did in the manual change test) and the test record was still there (the OfficeNumber did not change).

    I don't really care how it is done, I would just like a button that would change this specific value to 0.
    Last edited by jik_ff; 05-22-2012 at 08:48 AM.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    it's be helpful to see the db file.

  8. #8
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    Ok, here is a copy of the file:
    http://jikbyond.webs.com/Storage/Sam...ayout20121.TXT

    This is a zip file, but I could not upload it here (work firewall issues) or to my outdated site as a zip. So I changed the extension to TXT, just change it back to ZIP and extract the access file.

    The employee data is under #StaffList. I have 2 sample employees with an office number of 4028. You don't need to run the main form (it's all rough stuff right now anyway), just open the #OfficeAssignedSub form. at the prompt enter 4028, and you will see the 2 names listed. the officenumber field is unlabeled, but it will be hidden later, will be what you entered. If you go into the field, you can change the number, close the form and re-open, the entry will not show up. But the Remove button does not work.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    the remove button works for me. sets the control to 0.

  10. #10
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    Really? I just tried it again, and still nothing. I am using Access 2007. Are you using the same version? Is the change apparent right away in the form?

    Could the VB script be different? I know there are issues with VB script over the years of Access, I recently had to fix up an access 2003 file that was limping along from access 98. The Scripts would crash once and a while.

    Is there a way to do this with out VB? Expression code possibly?

    Ok, my bad... Forgot about the security warning. When I accept that, it does work. Ok, a side to this issue is that the people that will be using this form will need something simple. It will be shared off the network, but I don't want them to have to click the security warning all the time...
    Last edited by jik_ff; 05-22-2012 at 12:33 PM.

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    no, I'm using 2010 and yes, the change happens soon as I click the button. is your office 2007 up to date with all service packs and updates? (I don't know about access but excel 2007 is worthless before sp2)

  12. #12
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    Got it working, if you see my edit above. Would like to get away from having the end user have to remember to allow the security (can you open the security on a server share? Will have to find that out later), but I don't think I can do what I want with expressions.

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Cannot alter query data

    can you make the database location a trusted folder for the users?

  14. #14
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Cannot alter query data

    I can, but the admin staff cycle quite often, didn't want to have to administrate that for ever... ah well. Thanks again. It's working well enough to continue on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1