473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Computing dates from multiple tables

759 512MB
Hi all !

I think is a basic question but I am newbie in Access.

Situation:
- I work in an unbound form.
- In current database (say DB) I have a table (say TBL) with fields (say F1, F2 ... Fk ... Fn) and, of course, many records.
- I dimension a variable (say V).

Ask:
Please, teach me, step by step, how refer TBL and how I can to "scan" TBL with step S on the field Fk to obtain something like this:

Expand|Select|Wrap|Line Numbers
  1. V = 0 'Initiate V
  2. i = 1 'First record
  3. do until i > last record 'Escape from DO
  4. V = V + ValueFrom(Row=i,Field=Fk)
  5. i=i+S
  6. loop
Actually, for this purpose, I use a not visible LISTBOX based on a query and I use the .Column(Column,Row) . Ugly.

Thank you in advance.

One more question: How to use CODE TAGS to indent lines ? Thank you.
Apr 14 '11 #1

✓ answered by TheSmileyCoder

You can use:
Expand|Select|Wrap|Line Numbers
  1. rsDao.AbsolutePosition=10
for example.

or if you have the primary key field named KEY_Customer:
Expand|Select|Wrap|Line Numbers
  1. RsDao.FindFirst "KEY_Customer=10"
I sometimes open a full recordset, then use this method to cycle through some of the records:
Expand|Select|Wrap|Line Numbers
  1. Dim strCrit as string
  2. strCrit="KEY_Customer=10"
  3. rsDao.FindFirst strCrit
  4. Do while not RsDao.NoMatch
  5.  'My manipulation here
  6.  
  7.   RsDao.FindNext strCrit
  8. loop

6 1514
TheSmileyCoder
2,322 Expert Mod 2GB
If you have a field named Amount for instance, you can do a DOMAIN sum on that, the function is called DSUM. You can look up more details in the access help file.

Expand|Select|Wrap|Line Numbers
  1. DSUM("[Amount]","[TBL]",WHERE)
The WHERE is optional, it could be something like "[CustomerID]=257"


I think is what your "really" looking for, but if I am wrong, just let me known, and I can give an example of using and manipulating a recordset.
Apr 14 '11 #2
Mihail
759 512MB
Thank you for reply, TheSmileyCoder.

No. The task is not to SUM a field.

There are two tasks in my example:
- To open a table and access the records without using a control (like ListBox or ComboBox). I do not know how to do that.
- To access a certain value into a certain record into a certain field. Something like in Excel: MyVar = cells(R,C). For Access tables, C is a field with a certain name.

YES. In the last row of your post you understand what I wish. Thank you !
Apr 14 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
To open a table (Or a query) you can use:
Expand|Select|Wrap|Line Numbers
  1. Dim rsDao as dao.Recordset
  2. Set rsDAO=CurrentDb.OpenRecordset("SELECT * from [tbl] ",dbOpenDynaset)
  3. 'data manipulation goes here
  4.  
  5. 'Cleanup
  6.   Set rsDao=nothing
  7.  

An example of such Data manipulation could be:
Expand|Select|Wrap|Line Numbers
  1. Dim V as Variant
  2. Do While Not rsDao.Eof
  3.   V=V+rsDao.Field(0)
  4.   'OR
  5.   V=V+rsDao.Field(5)
  6.   V=V+rsDao!MyFieldName
  7.   rsDao.MoveNext
  8. loop
Apr 14 '11 #4
Mihail
759 512MB
Thank you again TheSmileyCoder.

It is exactly what I am looking for.

One more question:
Is it possible to start at row... r > 1 ?
Or is necessary to use rsDao.MoveNext in a DO-LOOP or FOR-NEXT cycle until the cursor is on the desired record ?
Apr 14 '11 #5
TheSmileyCoder
2,322 Expert Mod 2GB
You can use:
Expand|Select|Wrap|Line Numbers
  1. rsDao.AbsolutePosition=10
for example.

or if you have the primary key field named KEY_Customer:
Expand|Select|Wrap|Line Numbers
  1. RsDao.FindFirst "KEY_Customer=10"
I sometimes open a full recordset, then use this method to cycle through some of the records:
Expand|Select|Wrap|Line Numbers
  1. Dim strCrit as string
  2. strCrit="KEY_Customer=10"
  3. rsDao.FindFirst strCrit
  4. Do while not RsDao.NoMatch
  5.  'My manipulation here
  6.  
  7.   RsDao.FindNext strCrit
  8. loop
Apr 14 '11 #6
Mihail
759 512MB
Thank you, TheSmileyCoder.
That complete solve my question.
Apr 14 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Petre Agenbag | last post by:
Hi List Me again. I'm trying to return from multiple tables, the records that have field "information_sent" between two dates. The tables are all related by means of the id of the entry in the...
1
by: E Arredondo | last post by:
Hi, I am about migrate from an old program database to MySql (Running under RH LINUX)and I'm wondering which is the best option to do : I currently have one file for each of my modules, (I'm...
1
by: Ahmet Karaca | last post by:
Hi. myds.Reset(); mycommand.SelectCommand.CommandText= "Select att1 from Ing as Ingredient, Pro as Product "+ "where Pro.ad='apple' and Pro.id=Ing.id"; mycommand.Fill(myds, "Product"); // Here...
1
by: Justin | last post by:
What is the best/easiest way to update multiple tables at a time? Can you recommend any tutorials? Thanks, Justin.
8
by: Jason L James | last post by:
Hi all, does anyone know if I can create a dataview from multiple datatables. My dataset is constructed from four separate tables and then the relationships are added that link the tables...
5
by: mimo | last post by:
Hello, I have seen samples on how to pull data from one table and save back to it using the Form View control. How do I pull from multiple tables and save back to multiple tables on one...
6
by: ApexData | last post by:
I have 2 tables: Table1 and Table2. Neither one has a primary key because each table will only have 1-record. My form is a SingleForm unbound with tabs (my desire here). Using this form, in...
0
by: redpears007 | last post by:
Morning all! :) I have a database with multiple linked tables. I have created a search form with one txt box, for entering search criteria, and a listbox for each of the tables to isplay the...
0
by: shivapadma | last post by:
i want to know how multiple tables are added to the MS word document using vb.net i wrote following code to insert one table in MS word document using vb.net 1.opened MS word document 2.inserted...
0
by: NareshN | last post by:
Hi All, I have this tables.I want to upload excel file data to multiple tables. Excel file consist of EmpName,1 week dates with data(TimeIn and TimeOut). I want to insert EmpName into...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.