Can Someone Solve This Vba Program
Oct 10, 2006
Following program i have written in access. what it does is from the query i have created picks up the sizes of doors. calculates hit1 by qty then it needs to put the value into another table alongside the correct sizes. the problem im facing is how do i update the value into another table. heres the listing.
Option Compare Database
Option Explicit
Dim Db As Database
Dim Rs1 As Recordset
Dim Rs2 As Recordset
Dim lf, rh, drw1, drw2, drw3, drw4 As String
Dim q1, q2, q3, q4, q5, q6, qty As Integer
Dim hit1, hit2, hit3, hit4, hit5, hit6 As Integer
Private Sub Command70_Click()
Dim rs1fieldcount As Integer
Dim counter As Integer
''Assign a mdb
''+++++++++++++++
Set Db = CurrentDb
counter = 0
Set Rs1 = Db.OpenRecordset("custdoorsize")
Set Rs2 = Db.OpenRecordset("cusdoorsbase", dbOpenDynaset)
rs1fieldcount = Rs1.Fields.Count
If Rs2.RecordCount = 0 Then
MsgBox "No record found in query"
Else
this is where the value will come from
Do Until Rs2.EOF
If Rs2.Fields!left_door_size <> Empty Then
lf = Rs2.Fields!left_door_size
hit1 = 1
q1 = hit1 * Rs2.Fields!qty
End If
If Rs2.Fields!Right_door_size <> Empty Then
rh = Rs2.Fields!Right_door_size
hit2 = 1
q2 = hit2 * Rs2.Fields!qty
End If
If Rs2.Fields!draw1_size <> Empty Then
drw1 = Rs2.Fields!draw1_size
hit1 = 1
q3 = hit3 * Rs2.Fields!qty
End If
If Rs2.Fields!draw2_size <> Empty Then
drw2 = Rs2.Fields!draw2_size
hit4 = 1
q4 = hit4 * Rs2.Fields!qty
End If
If Rs2.Fields!draw3_size <> Empty Then
drw3 = Rs2.Fields!draw3_size
hit5 = 1
q5 = hit5 * Rs2.Fields!qty
End If
If Rs2.Fields!draw4_size <> Empty Then
drw4 = Rs2.Fields!draw4_size
hit6 = 1
q6 = hit6 * Rs2.Fields!qty
End If
Do While counter <> rs1fieldcount
This is where it finds the correct sizes where it will display the qty value
If Rs1.Fields(counter).Name = lf Then
Rs1.Edit
Rs1.Fields(counter).Value = q1
End If
If Rs1.Fields(counter).Name = rh Then
Rs1.Fields(counter).Value = q2
End If
If Rs1.Fields(counter).Name = drw1 Then
Rs1.Fields(counter).Value = q3
End If
If Rs1.Fields(counter).Name = drw2 Then
Rs1.Fields(counter).Value = q4
End If
If Rs1.Fields(counter).Name = drw3 Then
Rs1.Fields(counter).Value = q5
End If
If Rs1.Fields(counter).Name = drw4 Then
Rs1.Fields(counter).Value = q6
End If
counter = counter + 1
Loop
If Rs2.EOF Then
Set Rs1 = Nothing
Set Rs2 = Nothing
Set Db = Nothing
MsgBox "Finished ....."
Exit Sub
Else
Rs2.MoveNext
End If
Loop
End If
End Sub
please help
View Replies
ADVERTISEMENT
Aug 31, 2007
I am having the same issue.
Can't seem to find a solution to my problem here or in a few reference books I have on my shelf here at work.
I inherited several access databases from my predecessor a while back and although I’ve fixed most of the pre-existing problems and re-programmed most of the queries and reports at this point I’m stumped on one issue. One of the access files forces me to save every query, form or report I create no matter what. If I create a query because I want to do a quick one time query I can’t just close it and say no to saving when I’m done, I have to save it and then go back and delete it if I don’t need it anymore. I can’t track down any setting or code anywhere in this one access file that would cause this behavior to be different than all of the other dozen or so databases I inherited. This becomes a big issue in the case of if I accidentally do a major change I didn’t mean to that the undo command doesn’t correct, if I go to close it saves the query if it’s been saved before and makes my error permanent and I have to go dig out the nightly backup to undo the mistake.
Any thoughts on where to find or change this setting would be great as I’ve run out of ideas on my own.
View 1 Replies
View Related
May 8, 2006
Dear My Friends
I want to solve the follwing matter.
** Enter-Invoive Number
** Enter-Amount
If the amount 1000> - Show stamp duty as $1
If the amount 1001-2000 -Show stamp duty as $.2
If the amount 2001-3000 - Show stamp duty as $3
If the amount 3001-4000 -Show stamp duty as $4
Like wise upto 50,000
If the amount 50,000 < Show stamp duty as $50
I want to above results in access report with name of invoce number, amount and stamp duty .Please help as soon as possible
View 1 Replies
View Related
Aug 23, 2007
I am fairly new to access and am curious if this is possible. I have a x number of procedures, I will use 4 as an example, with those 4 procedures I have a reference table that has certain devices for those 4 procedures that need to be compared against the device charges. ie
Procedure
1A
2B
3C
4D
Procedure Device Reference
1A has AAA,BBB,CCC,DDD
2B has AAA,EEE,FFF,GGG
3C has AAA,HHH,III,JJJ
4D has FFF,KKK,LLL,MMM
Device Charges has
AAA,III.LLL.ZZZ
Is there maybe a case statement that I can use to have access try to solve for the best combination of the devices with the procedure to give me the most matches possible and not match say AAA with 3C and LLL with 4D giving 2 out of 4 matches, instead of the result AAA with 1A,III with 3C, and LLL with 4D, and flagging ZZZ as not a match or it matches 3 out of 4
Im not sure if this is the best place for this but any help is greatly appreciated and if more information is needed please let me know thank you for your time in advance
View 3 Replies
View Related
Aug 31, 2006
I have looked all over for an answer, and I think there may have been a few examples on this forum that may have helped, but I only have Access 97, so can't open the example databases to fully understand!
Bascially, in the database I am trying to set up, I have Museum items, for instance a photo, and the database users would like to have a list of the names associated with that photo. (obviously for some items there will be no people associated with it, and varying numbers of people for other items!).
I need some way of having the 'associated people' data displayed on the item information form (or somewhere handy). And I need it to have the flexibility to account for differing numbers of associated people. Would using a subform solve this? And if I use a subform, where will that data then be stored? In its own table??
View 2 Replies
View Related
Nov 14, 2006
Hello,
My problem is this:
I want to retrieve some data from the database, the data is as follows:
pourcentage de processus évalués dans l’année
my problem is that when I am writing a querry for this...it gives me an error because of the << ' >> mark in the word << l'année >>
my querry is this...
strSQL = "insert into temp_indicateur (id,description) values(" & rs!id & ",'" & rs!description & "')
I am getting these values from another recordset.
Can anyone please help??
View 2 Replies
View Related
Jul 30, 2007
Hi there,
The recruitment database I have designed for work is okay in the main except for where I need to filter candidates depending on their skill sets. What I need to be able to do is filter candidates that possess ALL skills selected in a multiselect listbox...
Table structure runs as: Candidates (many) linked to Job Role (one) (because candidates can only have one job title (in theory anyway)
Candidates linked to Skills table via junction table (candidate having many skills / one skill belonging to many candidates blah blah)...I'm sure this set up is as normalised as I can get (I aint no expert tho)...
My solution so far (suggested by another forum) was 3 listboxes on a form that runs like...
ListBox 1 = Job Role (Manager, Team Leader, Clerk, etc - set to SINGLE SELECT because an employee can only have ONE job title (supposed to anyway LOL)...
ListBox2= Skills (Payroll,Audit,Taxation, etc - SET TO MULTISELECT because employees can have more than one skill)...
ListBox3 = Candidates (populated by making selections in ListBoxes 1 and 2)
It all works well but is VERY slow as I was told to use make table, append queries and quite a bit of VBA to make the WHERE clauses as SQL statements, etc
I've searched high and low all over the net and have found things that come close but I'm just not adept enough to work it out (I started Access late in life). I feel I need some kind of subquery that first of all finds all candidates that e.g. have ALL 3 skills selected in Listbox 2 (creating a recordset of one row per skill meaning each candidate is listed in the recordset for as many skills selected and then filtering again with a count function that only displays candidates with a count of 3 skills - this subquery would then be used to populate Listbox 3 -
Sorry if I've overcomplicated this but it seems such a simple thing to and I'm getting a lot of pressure at work having being trying to solve this for weeks...
Any help putting me in the right direction or if you know of any similar example databases that would help me learn more would be much appreciated
Regards
dazza61
View 4 Replies
View Related
Nov 30, 2004
Ok here is what was going on. I have an option group, I would select an option,
type in my search criteria into a text box, and click an event button. The program
would then search my database for that criteria and grab the emails of the individuals
meeting that criteria. A message box would then pop up, listed all the emails it had grabbed
I would click ok (my sendobject command is set to edit the email) and at this point instead of
opening the email to edit the program would crash.
After scratching my head for several days I moved on and have come back to this problem again
two weeks later, and within 15min I realized what was wrong. I guess it is good to walk away
and come back fresh sometimes.
What is happening is that the program does not account for entries in my database that do NOT
have an email.
Example, let us say we want to search a state...lets use the state of GA for example. If I have 5 entries
from GA with email addresses and one entry from GA without an email address, it will crash the program.
My only guess is that the way the program is setup is that it is grabing whatever data is in the email location.
It that location is blank, its grabing blank and crashing the program.
I need a way to discard the entries it searches that don't have email addresses or something...
Please help, this is the last item for this project.
Here is the current code:
Code:'Code by M. Walts'Important information! this code requires a reference to the Microsoft DAO object libraryOption Compare DatabaseOption ExplicitPrivate Sub cmdEmail_Click()'will hold the dynamic SQL queryDim strSQL As String'will hold the WHERE clause portion of our SQL queryDim strWHERE As String'will hold all the recipients of this messageDim strRecipients As String'the recordset we will use to get the emails of the records that match our criteriaDim rst As DAO.Recordset'if there is input in the search criteria, then we will run the query and send the e-mailIf txtSearch <> "" Then'if you have more buttons, just add mosr cases (the value of the radio button'= the Case number, so Value of the State radio button is 1, etc.)Select Case opgSearch.ValueCase 1strWHERE = "WHERE State = '" & txtSearch & "'"Case 2strWHERE = "WHERE PrayerSupport = '" & txtSearch & "'"Case 3strWHERE = "WHERE Denom = '" & txtSearch & "'"Case 4strWHERE = "WHERE PACTTrainer = '" & txtSearch & "'"Case 5strWHERE = "WHERE PACTPartner = '" & txtSearch & "'"Case 6strWHERE = "WHERE City = '" & txtSearch & "'"Case 7strWHERE = "WHERE Donor = '" & txtSearch & "'"Case 8strWHERE = "WHERE MailingList = '" & txtSearch & "'"Case 9strWHERE = "WHERE Conference = '" & txtSearch & "'" Case 10strWHERE = "WHERE YouthPastor = '" & txtSearch & "'"Case 11strWHERE = "WHERE PreviousCustomer = '" & txtSearch & "'"End SelectstrSQL = "SELECT EMail FROM tblUser " & strWHERE'run the query and get the results into the recordsetSet rst = CurrentDb.OpenRecordset(strSQL)'Loop through the recordset and add all the EMailsDo While Not rst.EOFstrRecipients = strRecipients & ";" & rst!EMailrst.MoveNextLoop'remove the first ; from the strRecipientsstrRecipients = Right(strRecipients, Len(strRecipients) - 1)MsgBox strRecipientsDoCmd.SendObject , , , , , strRecipients, "Email Subject", "Email Body", Truerst.CloseSet rst = NothingEnd IfEnd Sub'stops a ' entered in the field from breaking the queryPrivate Function SQLSafe(safeMe As String) As StringSQLSafe = Replace(safeMe, "'", "''")End Function
View 2 Replies
View Related
Jun 24, 2007
I am trying to design a database for the company i work for, and I am wondering what is the best program to use.
My database will be shared on a network, and many different users will be using it at once. Also, I need this database to allow vpn connections so that certain people can access the db from outside of the office. I am not sure if db programs would deny a vpn user access, it might not make a difference how people are accessing info, but i think its worhtwile to mention that.
I appreciate your help, even though you opinions may be just a little biased. but thanks none-the-less.
View 14 Replies
View Related
Dec 16, 2005
Hi all!
I have created a database with auto-archiving features. I have "working tables" that are populated when the product is moved to the correct process, in this case when it reaches the test department. When the product is moved out of the relevant process, the database runs several queries which archive the relevant data and deletes the records from the working table.
There are two working tables in the test department, one for test failures and one for rework activities. The question at hand is WHEN should I populate the working table for rework activities:
Option 1: Populate the table when the product moves to the relevant process. This will create and delete thousands of records from the working table every day. Using this method will cause my table to bloat to 50,000+ records that are constantly updated, appended, and deleted.
Option 2: Populate the table when (and IF) the product fails a test. This will keep the table to a much smaller size (around 2500 records) but requires the database to run several queries in the middle of the data entry process, significantly slowing my program.
So which is the faster/better process: Filtering a table of 50,000+ records or appending the working table when you need the data?
View 1 Replies
View Related
Jan 4, 2006
Hi,
I have a delimma and am not sure how to proceed. It falls under the "You want what? When?" category. Basically, I have created an Access program with several (13) related tables and numerous forms. This program mimics an interview we are using for research and has a lot of VBA coding behind it with quite a few skip patterns, value checking, etc. During the testing phase, I was asked to allow the user to be able to go back and check a response to any previous answer at any given point in time. I hear numerous clicks of people running away from this question. This one has me frustrated and not too happy. I am wondering if there is some way I can show a copy of any form and the data contained within it for the present ID? IF it is a copy then the data, I presume would be locked and the user would not be able to change it. Also, I would want to bring the user back to the point where they were prior to going backwards. Feel my pain yet? Of course as I ponder this I can envision that they are going to want to change a value, because maybe a respondent "changed their mind" about a previous question. But, I am sure they would not want to work their way back to where they were, but want to jump back (forward), all the while I need to insure that any skip patterns that may have changed due to a change in data are followed and if a question that was answered before is now skipped then that data needs to be cleaned. I am concerned that as I begin to meander through this issue that I will have "duplicate ID" issues because as I move backward, possibly through several forms and tables and then move forward again the DB will think I am adding two items rather than changing the one. I.e., it will think I have two identical IDs because it already has one from the original pass and as it moves forward and runs through the automated saves that the second pass would represent a duplicate ID, thus crashing the program.
I know this is a multi-pronged question, but I would like to hear some suggestions as to how others with more experience would handle this. I am grateful for your time in reading this and would be even more so for any responses.
Peace!
View 3 Replies
View Related
Aug 24, 2006
I have a bunch of files where I have to copy one piece of data from a field and paste it into a different field on many records...in sort copy once, paste many times. Currently I use Ctrl C for copy and Ctrl V for paste. I'd write a query to do this for me, but not every record is going to recieve the data.
I'm getting tired of having to press Ctrl V on the appropriate records. Is there way to program a function key to do the Ctrl V thing? That way, I'd only have to press one key as opposed to pressing two keys.
Any help offered is truly appreciated. Thanks!!
View 4 Replies
View Related
Feb 11, 2007
I am using Microsoft Developer and wish to email the program to my customer. With Developer, there are tons of files and a few folders, not just one exe. I realize I must zip to send a exe, but the folders are a problem, since WinZip, which is what I have, will not accept the folders, only files. I could ship like that but it would be a mess on my customer's end. Any suggestion would be helpful.
The reason I want to send this way is just for speed. Of course I can copy to CD and send that way.
Sharon
View 2 Replies
View Related
Mar 6, 2007
I have a database made in MS Access. It has forms that allow the user to do certain things, such as add to the database, and so on. I only want the user to be able to run a program that will run the one, main form i've created it (as well as any other form that the main for lnks to). how do I do this?
View 14 Replies
View Related
May 29, 2007
Hello. I have tried using the search function on the board but I cannot find an answer.
Is it possible to create an executable program to run the database?
I would like to have a computer that does not have Access installed, to be able to load and run the user interface that allows them to manipulate the database, as well as write to it. It doesn't matter if the tables are encrypted or not.
Thanks for your time.
EDIT: It appears that after writing this post, I realized I hadn't used the search term "executable." I found an answer here (http://www.access-programmers.co.uk/forums/showpost.php?p=586646&postcount=2).
View 7 Replies
View Related
Jan 19, 2007
hi,
whenever i key in some data into a form i will transfer the data into a table.
whenever i want to change some data in the form i will delete all the records in the table and re-add all the data from form into the table.
the abv method works. however, i find that it is not effiencent because it every time delete all the records and re-add in records.
how shall i code the program to make it only edit/delete the specific records only instead bulk delete and bulk add?
refer to (program.zip)
Private Sub cmdSaveFltQpi_Click()
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim sql As String
Dim f As Form
Dim i As Integer
Dim k As String
Set f = Forms!frmFltQpi
Set Db = CurrentDb()
Call DeleteRecords 'delete all the previous records
sql = "SELECT * FROM [tblFltQpiMonthly] Where tblFltYear = " & f.cboFltQpiYear
For i = 1 To 12 'transfer the data from form to table
Set rs = Db.OpenRecordset(sql)
If rs.RecordCount >= 0 Then
If IsNull(f("txtTotalJobs" & i) Or f("txtTotalRecurring" & i) Or f("txtTotalAirWC" & i) Or f("txtTotalAF" & i)) = False Then
rs.AddNew
rs![tblFltYear] = f.cboFltQpiYear
rs![tblFltMonth] = i
rs![tblFltTotalJobs] = f("txtTotalJobs" & i)
rs![tblFltTotalRecurring] = f("txtTotalRecurring" & i)
rs![tblFltTotalAirtestWC] = f("txtTotalAirWC" & i)
rs![tblFltTotalAirtestFailure] = f("txtTotalAF" & i)
rs.Update
End If
End If
Next i
Db.Close
End Sub
Private Sub DeleteRecords()
Dim sql As String
sql = "DELETE * FROM [tblFltQpiMonthly] Where tblFltYear = " & Me.cboFltQpiYear
DoCmd.SetWarnings False
DoCmd.RunSQL sql
End Sub
View 1 Replies
View Related
Oct 5, 2004
hi!
I'm doing a reminder program this program alerts you if you have things to do each day it has a code that I obtained on the internet wich retrieves the user name. My problem is that when I enter as a user a window shows up say my username and the number of things I have to do but I can't get it to count the number of things to do. I tried a query but it doesn't work (either it shows "#name" or it goes all blank)please help.
thanks in advance, newbiepr
View 4 Replies
View Related
Oct 12, 2005
I'm just wondering if anyone has made a very advanced budget management program using just access?? I tried to make one for myself but I just want it to advanced for my little knowledge of access. I would love to be able to keep track of all my expenses including everything bought from groceries to hair cuts. I would love to be able to take my receipt from walmart and enter everything bought and the price for each item. Then I would love to be able to at anytime search for soap and thing with soap in the Item name will be displayed with the location and the date and price. This way I can keep track not just what I spend on groceries but what I spend on mountain dew or what i spend on hamburger in a given time. This is just way to complicated for me! I hope someone can help me out here maybe give me a shell and let me try to fill in certain parts or if someone already has one that works kind of like this maybe i could just change a few things to the way i want it! I really appreciate this!!
Bass
View 4 Replies
View Related
Feb 9, 2006
I'm, pretty sure the answer to this is a resounding NO, but I thought I'd try it anyway.
I have an AutoID field that records the record number which I then use as a "CaseNo" in the database to track the progress through the system.
Is it possible to program this AutoId to include the year? That is CaseNo 1 would become CaseNo 2005/1.
It would also help to start at 1 again for the first case entered in 2006.
Thanks for any assistance.
View 3 Replies
View Related
Aug 3, 2006
Before I start on this seemingly endless journey of learning Access 2003, I thought it appropriate to ask the question;
Will this program do what I need it to do?
I apologise in advance if this is not the right place to ask the question, I am a complete beginner to Access 2003.
I want to make an electronic log book for the guys at work, there are 5 people of different trades who would need to keep the log.
A typical entry would be as follows
Mon 22/3/06 Alan Smith B Shift
Compressor house (heading)
No 1 compressor (plant)
Oil pump (component)
Filter cleaned (action taken)
Personel (heading)
John Jones (personel)
Phoned in sick at 15:00hrs, will phone tomorrow to update
Boiler house (heading)
No 4 boiler (plant)
Water vlave leak (problem)
Tightened gland (action taken)
There are many headings, probably hundreds of plant, thousands of components and actions taken
We would need to view events to particular plant or areas between certain dates, some personel would need to enter data, some would only view the data without being able to enter it, few would need to alter the data.
Is Access 2003 capable of this, should I start the journey?
regards
culedude
View 1 Replies
View Related
Sep 13, 2006
Hello all!
Please forgive me for being a COMPLETE novice at Access, but I am trying!
What I need to do, is have an ordered list, which has check boxes along side each item.
When the relevant items have been checked, I need to be able to save or export to CSV, with ONLY the items which have been checked!!
I need the list to be pulled from a seperate source (like an excel spreadsheet) so that it can be updated easily...
Can anyone help?
so...
Item 1 [X]
Item 2 [ ]
Item 3 [ ]
Item 4 [X]
Item 5 [ ]
Item 6 [X]
would produce a CSV file:
Item 1, Item 4, Item 6,
Simple enough?
View 1 Replies
View Related
Dec 10, 2006
Greetings:
I am looking for a program that will repair a MsAccess 2000 .mdb file. So far all I have been able to find is those that repair the tables, does anyone know of a program that will repair the entire file including the forms?
Thanks
Mickey
View 2 Replies
View Related
Feb 17, 2007
well i am trying to make a very simple program that would help me learn the capitals of each country. yes it is a weird thing to do but i just it might help.
anyway i started doing it using access and made a table with three columns primary key number, country and capital.
I started making a form and im tryin to make it so the program would randomly pick a country and i would have to choose from a list box the capital and i would have a command button which when i click will tell me if i am right or not and if i am not then it would say the right capital.
How should i do this?
p.s ino the basics of using the code builder
help much appreciated.
View 3 Replies
View Related
Apr 13, 2007
I believed that Access is a stable DB program. It looks like I may have to change this view. Yesterday, due to some fault in power supply (SMPS), my PC suddenly went off while I was working in my Access DB. My DB is a personal DB (single user). Today, after replacing the SMPS, when I opened my DB, Access gave a message that my DB is corrupted while it was being used last time. It asked to attempt repair with Yes/No button. I clicked the Yes button and it did nothing. In my third attempt, I was able to open my DB but I am worried whether it will work as before. Could the experts in this forum throw some light about Access DB' stability and measures to prevent corruption? Grateful for advice.
View 9 Replies
View Related
Jun 27, 2007
I made an Access DB program in my PC. I have 17 inches monitor and so I designed everything to fit in that screen. When it was deployed in the user's computer, it did not fit in his screen as he has only 14 inches monitor. The command buttons and other things were not visible and were out of view of the screen. I changed the screen resolution but it made the fonts look much smaller. I have used 12 pt fonts in my Prg. Is it possible to correct my forms so that it automatically fits in all sizes of screen?
View 2 Replies
View Related
Nov 13, 2007
I'm trying to run some VB code (in an Access module). The code executes for 10 seconds or so, and then Windows XP robs it of any CPU. I've tried (many times) using task manager to set the priority to high or real time, but still MSAccess shows as using only 2 or 3% of cpu.
I've got in intel core 2 due, running Windows XP SP2.
I've got a table with about 2 million rows. When I try to append the 2m into another table with an append query, or if I burn through the table with a do loop in VB using recordset.append and then recordset.update it takes forever (hours). What burns me up is that the CUP sits there near idle, varying from 2 to 4 pct usage.
Thanks for any ideas..
Steve
View 1 Replies
View Related