User Profile

Collapse

Profile Sidebar

Collapse
gnawoncents
gnawoncents
Last Activity: Jul 19 '19, 06:54 PM
Joined: May 31 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Thank you to everyone who took the time to look at this. I tried running the code on a new, blank worksheet and didn't get an error, so I did some extra troubleshooting and figured out what I was missing.

    I apologize--my original question didn't have all the information anyone would have needed to figure out the problem.

    My worksheet is protected and VBA unprotects it to make changes then re-protects it before closing....
    See more | Go to post

    Leave a comment:


  • Error 1004 on second line trying to set value or formatting of cell or range

    I seem to be missing an unstated rule here and am looking for some insight.

    I am running Excel 2016 on Windows 10 Enterprise and am getting an error when I try to set the value or formatting of a cell (or cells). The error itself (Run-time error '1004': Application-defined or object-defined error) doesn't tell me much.

    Key notes:
    - I get the error always on the SECOND line of code. The first works fine.
    ...
    See more | Go to post

  • gnawoncents
    started a topic Use a string to represent a range object

    Use a string to represent a range object

    Greetings,

    I am trying to find out if something is possible in Excel VBA. I would like to use a string or integer to modify/represent the name of a range object. Please note that I do not have a range stored in string format.

    For example, I have the following range objects already set: rng1, rng2, rng3, etc.

    I am looping through rows and want to change the associated range with each iteration, using either...
    See more | Go to post

  • Eric,

    First, remember to put your code in tags.

    In regards to your locking issue, it's not something your code is missing, rather, it's something extra it has. There are a number of ways to update a record. The simplest is to display the actual record in the form, then it automatically updates as changes are made. I will assume that this doesn't work for you for some reason, which is why you didn't take that approach. ...
    See more | Go to post
    Last edited by gnawoncents; Mar 14 '18, 08:29 AM. Reason: code tags fix

    Leave a comment:


  • twinnyfo,

    Very nice--much more elegant. *initiates slow clap*
    See more | Go to post

    Leave a comment:


  • Welcome to Bytes, cberos!

    I've read your post a few times, but am not sure I fully understand what you're trying to do. If you are saying that the ACTNUM filed has records ABCDE, FGHIKD, and ZADET and you want to create a string with them all, then that's simple enough. Please explain in a little more detail and give an example of starting records and what your expected outcome is. Thank you.
    See more | Go to post

    Leave a comment:


  • Welcome to Bytes, privateguy!
    Your answer will depend on how you are trying to do this (VBA or Query/SQL). Regardless, you will have to do a two-step process that first finds all unique records, combining ShowDate and Customer. Next, based on those results, count how many are for any given day (anything over 1 means that at least two different people where shown properties on that day). Below is some SQL you can plug into two queries, if you...
    See more | Go to post
    Last edited by gnawoncents; Mar 5 '18, 09:10 AM. Reason: Edited to add space for clarity

    Leave a comment:


  • Liam,
    Welcome to Bytes! There are a couple issues keeping you from the answer you want. First, anytime all the numbers are the same (not just zeroes), the code won't be able to handle it because you're filtering out all the variables. You can solve this by counting how many times the numbers are the same--if they are always the same, just force insert what you want into the field (since there is no second-highest number, I'm not sure what this...
    See more | Go to post

    Leave a comment:


  • Eric,

    You could write a procedure that checks the state of each toggle. If all have been clicked, then the Save Record button is enabled. If not, it is disabled. Call it when the form opens (disabling the button) and then in the After Update event of each toggle button. That way when each has been clicked, the button will enable.
    See more | Go to post
    Last edited by gnawoncents; Feb 27 '18, 05:09 AM. Reason: edited for typo

    Leave a comment:


  • You are quite welcome!
    See more | Go to post

    Leave a comment:


  • Try this as the SQL for your Query:
    Code:
    SELECT Table2.ID, DLookUp([Table2].[Opts],"Table1","[Table1].[ID] = " & [Table2].[ID]) AS [Values]
    FROM Table2;
    See more | Go to post

    Leave a comment:


  • Angela,
    We understand your concern. In your first iteration, 10% would be fine. The only problem is if you then took 10% of the remaining 90%, you're actually only getting 9% of the total records for the second iteration. In that sense, yes, you need the original number saved somewhere. Or, the code I suggested earlier could get you there all at once and be ready for future use. If, however, you need it saved in a separate query, but automatically...
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Calculating years between dates
    @Narender, as I read it, Stephcar wants the number of years between the current date and some past date. Dividing by 365.25 is one way of getting the difference converted into years.
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Select Top different number of records
    @Rabbit already pointed out one option, which will work if, as already stated, the QID is "always sequential starting from 1 for any chapter."

    In order to find the best solution, however, we need some more information on how the results will be used.
    - Will the results be displayed immediately to a form/report? If so, you could just create/modify the form's/report's filter.
    - Will the results be used to do further...
    See more | Go to post
    Last edited by gnawoncents; Feb 22 '18, 09:21 AM. Reason: fixed typo

    Leave a comment:


  • gnawoncents
    replied to Calculating years between dates
    Welcome to Bytes, Stephcar!
    Writing your code that way is actually giving you 12 divided by 31 divided by 2012 minus CurrentDate divided by 365.25. That is why it's returning a negative value. if 12/31/2012 is a fixed date, you're probably looking for something like the code below.
    Code:
    (Date - DateValue("12-31-2012")) / 365.25
    If it is not a set date and can change, check out NeoPa's caution on setting up dates...
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Select Top different number of records
    So, just to make sure I understand, the user selects a ChapID and you want the query to return the top X records from MyTable where X = the NoOfRecs that correspond to ChapID, regardless of QID.

    If so, and you are already using QueryDef to update the "Top X" records, all you need to do is replace X with a Dlookup to find the number of records you want to return. If you haven't already built all this, there are other options...
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Include all data in listbox to a report
    NeoPa,
    Thank you for the clarification. I will be more careful with dates and strings from here on out!
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Select Top different number of records
    When you say:

    ...are you saying that the user will input/select the ChapID?

    Also, is there any reason the NoOfRecs couldn't go on the same original table? That would make it a little simpler. Either way, you could modify your query using a dlookup to find the number of records based on the selected ChapID.

    I get the feeling though that there is something here I'm missing. Could you explain in a little more...
    See more | Go to post

    Leave a comment:


  • gnawoncents
    replied to Include all data in listbox to a report
    NeoPa,
    Thank you for the warning. I read your linked article. Just to make sure I understand correctly--you're saying that the date format needs to be identified inside the command line? Would it be different depending on where one is in the world or only on how it is already stored in the database? I don't want to lead anyone astray and appreciate the insight!
    See more | Go to post

    Leave a comment:


  • Angela,

    Below is some code you may find useful and can modify to meet your needs.

    Assumptions:
    - There will be no changes to the inventory items (no record additions or deletions) once imported
    - You wish to inventory 10% of the total records every month
    - After 10 inventories, you want to have inventoried 100% of total inventory
    - You want to inventory a new random 10% set for each of months 11...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...