If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Lookup count number

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-09, 04:15
Bob2119 Bob2119 is offline
Registered User
 
Join Date: Jul 2009
Posts: 181
Lookup count number

I have a flight db that keep track of rc control airplane flights. I need to get the last cycle number for a battery when entering a new flight but can not figure out how to do this in access.
Reply With Quote
  #2 (permalink)  
Old 07-03-09, 04:20
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
is your cycle number ascending numeric
..if so select my,column,list, max(cycleno) from mytable where aircraftid=blah
is your battery usage time satmped
...if so select top(1) batteryuse from mytable
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 07-03-09, 08:15
Bob2119 Bob2119 is offline
Registered User
 
Join Date: Jul 2009
Posts: 181
cycle# is ascending numeric in the battery table. when adding a flight I need the cycle # in flight to lookup the cycle# in battery add one to it store than in battery and enter it in flight cycle field.
Sorry I am very good at Clarion programming but very new to Access and don't understand your answer.

Quote:
Originally Posted by healdem
is your cycle number ascending numeric
..if so select my,column,list, max(cycleno) from mytable where aircraftid=blah
is your battery usage time satmped
...if so select top(1) batteryuse from mytable
Reply With Quote
  #4 (permalink)  
Old 07-03-09, 14:08
Bob2119 Bob2119 is offline
Registered User
 
Join Date: Jul 2009
Posts: 181
Question

I think I found the right place for the code. After searching the net for samples I have tried the following. But of course this don't work.
I did get "voltage = 10" to work but not "cycle = 10" for some reason. Is there a different syntax for a string field vs a number field.
No one in my town has a book on Access.

I sure would appreciate the help.

Private Sub Cycle_BeforeUpdate(Cancel As Integer)
'Ensure right battery record
SELECT Battery.ID, Battery.Description FROM Battery;
'Calc new cycle number
Cycle = battery.Cycle + 1
'Updata battery total cycle
battery.Cycle = Cycle
'
End Sub
Reply With Quote
  #5 (permalink)  
Old 07-03-09, 17:27
Bob2119 Bob2119 is offline
Registered User
 
Join Date: Jul 2009
Posts: 181
Well I found a better place I am now using before update on the battery
and cycle to icycle. It appears cycle is a key word. Also I need [] around names with spaces.
Reply With Quote
  #6 (permalink)  
Old 07-03-09, 21:53
Bob2119 Bob2119 is offline
Registered User
 
Join Date: Jul 2009
Posts: 181
I got it working needed [] and I add a i,s,d before every field name and each description name are all different. One line of code.
[battery.ibtotal cycles] = [battery.ibtotal cycles] + 1

Here is what a friend said I needed to start with I have no idea what it is

Private Sub Battery___Change()
Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM [Battery] where ID =" & Battery__.Text
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 3, 3
rs("Total Cycles #") = rs("Total Cycles #") + 1
Cycles = rs("Total Cycles #")
rs.Update
rs.Close
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On