I am trying to create a database that saves marathon times to a database. The way the times are marked are in minutes and seconds. There are 8 sections to the marathon and the times will have to be added together later on (another problem entirely that I will deal with later. :) After researching the best way to do that I found that it is recommended that I convert the minutes to seconds and add the rest of the seconds together and just store the time as an integer. Well I created a form and for time I created two combo boxes, 1 for minutes and 1 for seconds. My plan was to add a button and when that is clicked it will create a new variable(totalTime) and multiply the minutes by 60 and then add the seconds. Now my question is how to get that variable's data into my table? I tried an insert into and it gave me an error. Is the insert into the best route or is there another path I should try?
I feel like I am missing something easy and any nudge in the right direction would be much appreciated.
5 2337
I am trying to create a database that saves marathon times to a database. The way the times are marked are in minutes and seconds. There are 8 sections to the marathon and the times will have to be added together later on (another problem entirely that I will deal with later. :) After researching the best way to do that I found that it is recommended that I convert the minutes to seconds and add the rest of the seconds together and just store the time as an integer. Well I created a form and for time I created two combo boxes, 1 for minutes and 1 for seconds. My plan was to add a button and when that is clicked it will create a new variable(totalTime) and multiply the minutes by 60 and then add the seconds. Now my question is how to get that variable's data into my table? I tried an insert into and it gave me an error. Is the insert into the best route or is there another path I should try?
I feel like I am missing something easy and any nudge in the right direction would be much appreciated.
- Post all relevant information such as: Table Structure, Field definitions including Data Types, Names, etc. especially the [Minutes] and [Seconds] Fields.
- What's your Form Name, Combo Box Names, etc.
- Post the INSERT INTO code that is not working.
- How are the Minutes and Seconds data stored? Are there Minutes and Seconds Fields for each section of the Marathon?
- I think you got the idea...
The Race table is BibNum, RaceNum, Time (an integer).
On the form (Form_Race) I have a combo box with the race number (values are stored in row source. Bib Number, a text field.
Time: there is a minutes combo box from 20-180 (stored in row source) and a Seconds Combo box (0-59). These are not tied to a control because I want to use them to calculate a new variable.
This is my code:
Dim totalTime As Integer
totalTime = cboMinutes * 60 + cboSeconds
INSERT INTO Race (BibNum, RaceNum, Time) VALUES ([Form_Race.BibNum],[Form_Race.RaceNum],totalTime)
Error message (Stops on Race) Compile Error: Expected: end of statement
The Race table is BibNum, RaceNum, Time (an integer).
On the form (Form_Race) I have a combo box with the race number (values are stored in row source. Bib Number, a text field.
Time: there is a minutes combo box from 20-180 (stored in row source) and a Seconds Combo box (0-59). These are not tied to a control because I want to use them to calculate a new variable.
This is my code:
Dim totalTime As Integer
totalTime = cboMinutes * 60 + cboSeconds
INSERT INTO Race (BibNum, RaceNum, Time) VALUES ([Form_Race.BibNum],[Form_Race.RaceNum],totalTime)
Error message (Stops on Race) Compile Error: Expected: end of statement
This will do the trick for you. - Dim totalTime As Integer, strSQL As String
-
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
-
Set MyDB = CurrentDb
-
Set MyRS = MyDB.OpenRecordset("Race", dbOpenDynaset)
-
-
totalTime = (Nz(Me![cboMinutes]) * 60) + Nz(Me![cboSeconds])
-
-
With MyRS
-
.AddNew
-
![BibNum] = Me![BibNum]
-
![RaceNum] = Me![RaceNum]
-
![Time] = totalTime
-
.Update
-
End With
-
-
MyRS.Close
-
-
Me.Requery
Thank you so much for trying to help me. I typed in what you wrote and it gave me a new error:
Compile Error: User-defined type not defined
It highlighted the 'Dim MyDB As DAO.Database' part
Thank you so much for trying to help me. I typed in what you wrote and it gave me a new error:
Compile Error: User-defined type not defined
It highlighted the 'Dim MyDB As DAO.Database' part
Your Reference to the Microsoft Data Access Objects is not set. If you are using ADO, then the syntax should be: - Dim MyDB As ADODB.Database, MyRS As ADODB.Recordset
Sign in to post your reply or Sign up for a free account.
Similar topics
by: steve |
last post by:
Hello,
I am trying to import an image file into a form. This would be a
persons picture saved in the same directory for every unique record.
I don't have any problems making an action button to...
|
by: Stuart McGraw |
last post by:
I haven't been able to figure this out and would
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've...
|
by: RCS |
last post by:
I have an app that I have different "sections" that I want to switch back
and forth from, all while having the server maintain viewstate for each
page. In other words, when I am on Page1.aspx and...
|
by: AxOn |
last post by:
Hi,
How can i save the specific RichTextBox in the selected tab if i have
several tabs with RichTextBoxes in? The application is a text editor
type program and when i try to save the most...
|
by: Magnus |
last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables).
http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx
In the famous Customer/Order example, I'm getting referential...
|
by: Andy_Khosravi |
last post by:
I'm having a problem with an entry form on one of my applications. It
would appear that the save action is sometimes not working, and is
generating no error when it fails. I'm hoping one of you may...
|
by: =?Utf-8?B?emlyb3M=?= |
last post by:
We have a need, after a user fill out a form, to save that page (aspx)
and to send it as attachment by email , and to save it to a database for later
retrieval
any ideas how to save the aspx...
|
by: paulcis |
last post by:
I am trying to produce a dynamic form from a database with unknown
amount of records.
I need to read the values and create a new textbox for each.
I need to create the textboxes at page_init stage...
|
by: Ajm113 |
last post by:
Contributing To: Saving RichTextBox from Tab Control
Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread?...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |