Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 6th, 2005, 08:28 AM
mainy mainy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 4 mainy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 4 sec
Reputation Power: 0
Can Anyone Figure This Out?????

Hi, I have a database:-

http://uk.geocities.com/mainymainymainy/db1.mdb

I am trying to do a report on Query1 (values column). I just cant seem to get the blank fields to populate with the previous fields. can anyone help?





What i want the database to do is populate the "value" of the previous value if there is no value present. As i am tracking changes and need to produce graphs. So if there is no value there on a date then it will find the previous value and populate itself with that value.

So if on the 01/01/2005 the value is 10
And on the 02/01/2005 the value is null - how do i get the value to be 10?


Do i need a dlookup statement?

Any help would be great,
Cheers,
Mainy

Reply With Quote
  #2  
Old April 6th, 2005, 09:26 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 5
Quote:
Originally Posted by mainy





What i want the database to do is populate the "value" of the previous value if there is no value present. As i am tracking changes and need to produce graphs. So if there is no value there on a date then it will find the previous value and populate itself with that value.



So if on the 01/01/2005 the value is 10
And on the 02/01/2005 the value is null - how do i get the value to be 10?


It looks like makeup, please don't do it or at least do the estimation of the value with a more statistical aproach.
But still, You can browse across the database, and check the value if IsNull(regs!value) if so update the value (sorry I couldn't see your database, maybe my VB6 has not the right version of visual data manager).

Reply With Quote
  #3  
Old April 7th, 2005, 04:04 PM
NecroLyte NecroLyte is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: South Africa
Posts: 5 NecroLyte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 12 sec
Reputation Power: 0
how bout dmax

how about using dmax - something along the lines of:
dmax("value","table1", {date on tbl} < {date of current record})

should return the previous value before the current records date

Reply With Quote
  #4  
Old July 23rd, 2005, 07:43 AM
Gary O'Connor Gary O'Connor is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Cookamidgera, a little village in the centre of New South Wales, Australia. Sydney is my states capital city.
Posts: 5 Gary O'Connor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
This might help.

This is one way to do this in VB6. I hope that is what you are looking for.

There are two additional functions here which are absolutely invaluable when using DBs in VB.

Anyway I hope it helps.

'***************

Private SetDBValues()
Dim prevVal As Integer
Set dbTable = OpenDatabase("db1") 'With appropriate path
Set rsField = dbTable.OpenRecordset("SELECT * FROM Query1")
rsField.MoveFirst
prevVal = ChkIVal(rsField.Fields("Value").Value) ' Get the value of the first record
With rsField
While Not .EOF
.MoveNext
If ChkIVal(.Fields("Value").Value) = 0 Then 'If the value of 'Value' =0 then
.Edit 'edit the record
.Fields("Value").Value = prevVal 'make this 'Value' = the previous 'Value'
.Update 'and update
Else 'or
prevVal = ChkIVal(.Fields("Value").Value) 'update the previous value to this record's value
End If
Wend
End Sub


Public Function ChkIVal(DataB As Variant) As Integer
'Interesting function which returns the Integer value of the
'supplied variant.

If IsNothing(DataB) Then
ChkIVal = 0
Else
ChkIVal = CInt(DataB)
End If
End Function


Public Function IsNothing(Value As Variant) As Boolean
'Interesting function to test if there is any value to the
'passed variant.

Dim vTest As Variant
Dim iArrayStart As Integer
Dim iCtr As Integer
Dim bFlag As Boolean

If IsEmpty(Value) Then
IsNothing = True
Exit Function
End If

If IsNull(Value) Then
IsNothing = True
Exit Function
End If

If VarType(Value) = vbString Then
If Value = "" Then
IsNothing = True
Exit Function
End If
End If

If IsNumeric(Value) Then
If Value = 0 Then
IsNothing = True
Exit Function
End If
End If

If IsObject(Value) Then
If Value Is Nothing Then
IsNothing = True
Exit Function
End If

End If

If IsArray(Value) Then
On Error Resume Next
vTest = Value(0)
iArrayStart = IIf(Err.Number = 0, 0, 1)
Err.Clear
On Error GoTo 0
For iCtr = iArrayStart To UBound(Value)
If Not IsNothing(Value(iCtr)) Then
bFlag = True
Exit For
End If

Next
IsNothing = Not bFlag
End If

End Function

'*********************

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Can Anyone Figure This Out?????


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT