Modules & VBA :: Find Combo / Sum That Equals Target Value?
Jul 12, 2013
I want to ensure that employees submitted expenses that were actually valid. In table 'Payments', I have the employee ID and amount paid to that employee's account. In table 'Expenses', I have the employee ID and then the individual expenses the employee submitted. How can I create some VBA to find combinations of the employee's records in 'Expenses' that equal the total amount paid for that same Emp ID in table 'Payments'? My ideal end-result would be a report showing each employee IDs with the expenses and then the amount paid beside it. The below is a good start but I need to make it loop through every unique Employee ID.
I have a form (PostProductionForm) which is used to input data about finished goods which come off a production line. There are three possible outcomes which can occur after the production: Passed, Reprocessed, Failed and the numbers for these are entered in 3 text boxes on the form (QtyReprocessedTxt, QtyFailedTxt, QtyPassedTxt).
These text boxes are auto populated with a 0 from the table (PostProductionTbl) so there aren't blanks.
What I am trying to do is use an IF function (I think) which says that if Quantity Reprocessed is equal to zero when the submit button is pressed, the "Reason for reprocessing" combo (RPReasonCombo) must have something selected (i.e. can't be blank) or it won't go to a new record.
I have two forms. In form 1, there is a combo box that I have set on click to open form 2 in this manner:
Code: Private Sub boxEditEntry_Click() DoCmd.OpenForm "frmSRTEdit", , , "[ControlNumber]=" & Me.boxEditEntry End Sub
The thing is, this has only worked when Form 2 is already open. I can't figure out why. If Form 2 is not open or has not been opened, the on click will still open Form 2, but not to the value in the combo box, or any value for that matter, it's blank. I really need it open if has not yet been opened or if it has been closed before. Also, I'm fairly new to access and I have no clue what I'm doing in vb.
Trying to make a shortcut to join the workgroup and open a Db.
I made a shortcut for a Db, the shortcut defalt target was: X:RC-OfficeRC_OFFICdatabaseProjects.mdb
I edited the target line to: /wrkgrp ”X:RC-OfficeRC_OFFICdatabaseMS Access Workgroup.mdw” “X:RC-OfficeRC_OFFICdatabaseProjects.mdb”
I get wrkgrp not vaid target. I put the mdb file path first, I get not vaid target for the path to the Db. I would rather not put in the whole MS Access program file. This is on a server that I don't know much about. Not sure I would get the program file right. Help?
sql = "SELECT Table1.* INTO Table1 IN '" & sExpFileName & "' FROM Table1" CustDB.Execute sql
where the sExpFileName contains the path of The Target MS Access DB The Query works fine. But recently I discovered that if my target File name contains apostrophe It gives error as Query Input must contain at least one table or query
Is there any way to solve this problem. Please suggest me some way
I have a table with data of people, in which table two fields contain two (not necessarily different) jobs.
I want to build a query (and later a report based on that query) which will return the name, address, phone of the person, plus only the field of the job that I asked for it. when executing the query, the user should enter the asked job in a popup-box using the below formula.
Like "*" & [job] & "*"
Note, that there may be records containing in both job fields the same job. I want to get the field only if it contains the asked job.
I have had a look at quite a few threads, but cannot find what i need. I am looking to show a command button if the value typed into the text box equals one of the values in the query. I understand how to show/hide a command button due to another post, but it is getting this to happen IF the text box matches one or more of the values in the query.
I have txtCustNo as the text box to type a number into I have qryCustNo as the query name i have cmdFindCust as command button
Should i have the code under the "after update" part of the text box also?
I need to know if it is possible to create a delete query which will target particular fields in a row based on certain criteria in a seperate combo box(on same table).
The few ways that I have tried to do this have been unsuccesful so if anyone can shed some light on the subject it would be greatly appreciated.
I have to make a query using the following case, I have two tables, in the first table i have the materials and its received date and in my second table i have the month the target date for every month to receive the material. Now linking this two tables, i want to see the from the first table on every month hom many materails i received after the target date how to do this.
Table 1 Field1 Date Field2 Month Field3 Material Field4 received_date
I have my Jobs form which has a sub-form for all the different parts used on that job which then calculates the total charge and displays this on the main jobs form. Now how would I get this value to be stored in table tblJobs on the record where the ID = JobID on Jobs form. I need to do this to display the total on a report.
Looked around and couldn't find what I was looking for, is there a visual basic command to set it then I can use docmd.saverecord after or what would I need to do?
Or is there an SQL statement to do this I could execute on a button click or something similar?
why =listboxname.column(0) in the control source of a textbox will give me the value "#name?" ? I've used it successfully on another form..but for some reason its not working for me.
I have six fields in a record that look like Median.University1, Median.University2, Median.University3, Median. University4, Median.University5,Median.Unive rsity6. How can I create a calculated field that counts where values equals 4 in the fields . I have tried Dcount and Count with no success.
I have a macro that needs to run repeatedly until the number of records in a query =0 but I can't seem to get the Repeat Expression set properly.
My query is called sqMatchCount:
SELECT Count(sqCompare_Parts_Matched_1st.BRP_Entry_Num) AS MatchCount FROM sqCompare_Parts_Matched_1st;
The theory is if I don't have any more matches then I do not want the macro to run any more. In other words, MatchCount will = 0 when there are no more matches.
I have tried a variety of syntax using DCount in the Repeat Expression:
=DCount("*","sqMatchCount") ...... Macro runs in a continuous loop DCount("*","sqMatchCount")=0 ...... Macro does not run (although I thought a couple times it actually DID run with this syntax) DCount("MatchCount","sqMatchCount")=0 ...... Macro does not run =DCount("MatchCount","sqMatchCount")=0 ....... Macro does not run =DCount("MatchCount","sqMatchCount") ....... Macro runs in a continuous loop
What IS the proper way to write this Repeat Expression for the RunMacro Action if I want it to run as long as sqMatchCount.MatchCount>0?
I have a form, which i use to book in products received. What i want to do is if the quantity received is equal to what was ordered then i'd like to update a yes/no field (Order Complete) on a separate table to true.
I have a search form with 1 combo box and a button which when the user inputs an invoice number and clicks the button, a main form is opened for that particular record.
The problem I have is to display an error message before the main form opens if the user has either left the combo box blank or they have input an invoice number that doesn't exist.
I have a form and I have added a combo box to quickly find records. I used the wizard to set this up as I did not know the code. Anyway this works, but it displays the wrong value - it displays the ID number and not the text value from the table.
The record source is a table not a query.
What am I doing wrong here, I have tried changing the control source and it doesn't work.
I have a combo box at the top of a form which is used to find records. When new records are added using the form, they do not show up in the combo box until the form has been closed and reopened.
Can anyone tell me how I can requery the combo box to ensure that it does list newly entered records?
I have a form for accounts, which has a subform listing the customers within each account.
On the customers form I can use the wizard to add a combo to find a record, but if I want to add a similar combo within the subform, the option does not appear in the combo wizard.
Can anyone enlighten me on why/how to resolve?
Many thanks
Mark
(using Access 2003 on an Access 2000 format db, Win XP Pro SP1)
I have a main form that has fields from different tables. This is a research study, so each form enters data into different tables. Well, each record is a person's data. Instead of scrolling through each record, I need an option on the main form that allows me to search for a specific person and have their data populate into the form.So far I am able to make a combo box that pulls up the record from one table. Well, HOW do i do it from ALL the tables!?? Do I have to make a query?
I have three objects a Main_Table , ClientDataForm and a MapForm all three share a common ClientID number
From that Main_Table I have created a ClientDataForm form which I enter all Data
From ClientDataForm I wish to create a button on it which runs a Macro that Saves ClientDataForm Record and then populates another form named MapForm with whatever record is currently open in Form One whether a newly created one or previous record.
How would I write this code for that button? Also why I would write it that way?
message "cannot find the object "." ". I have looked in the VBA for the Report I am working with and the form that has the underlying data and cannot find the rouge period! I am creating a label for payment envelopes that is gets its data from the form that indicates payments made
I'm lost on how to use the LIKE to find a value in a field.
I try to use the open folder if a field contains "Retail" or any other containing as a part. So, I could have just "Retail" "New Retail" and then act on it.
How can I use the below proper?
Code: If Me.Business_Type Like "*" & "Retail" Then
I have an unbound textbox in a form which is filled with a text value eg "RWL" when the form opens. I now need another textbox that goes to the Company Data base finds the "RWL" text and finds its Primary key and puts it in the new textbox?