 |
 |

08-06-2002, 01:24 PM
|
|
|
Database problem for database Guru`s
|
Hi Guys,
I would appreciate it very much if someone could help me with the following:
I have created a database application by making use of an Ms Access database format (not ODBC). The application consist of the following:
fMain (Main form)
fTest (Second form)
Database: Database name = UserInfo.mdb
TableName: PersInfo
The table has the following fields: Name, Surname, Gender, Test_Result, Time_of_test, Date_of_test
I have created the first form by making use of the VB Data Form Wizard. Thus, the first page has the following components:
- datPrimaryRS
- picButtons [ New, Add & Proceed buttons]
- three edit boxes were the following must be entered: Name, Surname, Gender
The first form asks the user his personal information like, Name, Surname etc. The user enter his details at the first form (and do not update the database yet) and click on a proceed button to go to the second form. At the second form the user complete a test. After the test is completed, he clicks on a button, btnCompute. The result of the the test are displayed by making use of a label, lblResult.
Now here is were I need help: When the user clicked on the compute button, the results that are displayed by the lblResult (label), must also be written to the database. The database must then be updated so that the final data in the database should look like this:
Name: James
Surname: Bond
Gender: Male
Test Result: 78%
NOTE: As you noticed, the data of the first form (fMain) are part of the data (test result) of the second form (fTest). I need some help on how to do this.
The second problem that I am having is the following:
As part of data in my database, I want to write the system time & date at the moment the update button is clicked. (If possible the system date must also be written to the database) – all together with the details of the user that he have entered at the first form. For example:
Name: James
Surname: Bond
Gender: male
Test Result: 78%
Time test was completed: 09:15
Date: 06/08/2002
I am not really sure how to implement this – would appreciate some ideas…
JUST TO PROOF TO YOU GUYS THAT I HAVE ACCTUALLY TRIED, HERE IS MY CODE – BUT I AM HAVING PROBLEMS WITH IT:
Sub btnCompute_Click
Dim CurrDateTime as Date
Dim NewRec as ADODB.RecordSet
CurrDateTime = Now()
TestRes = <compute test results>
Set NewRec = New ADODB.RecordSet
With NewRec
.ActiveConnection = frmMain.fADO_Connect
.AddNew
.Fields("Name") = frmMain.txtFirstName.Text
.Fields("SurName") = frmMain.txtSurName.Text
<populate the rest of the fields>
.Fields("Results") = lblResult.Caption
.Fields("TimeOfTest") = CurrDateTime
.Update
End With
Set NewRec = Nothing
End Sub
Thanks guys
Regards
C - Power
|
|

08-06-2002, 01:33 PM
|
 |
Disillusioned Code Poet
Retired Moderator * Guru *
|
|
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
|
|
|
I don't see anything immediately wrong with that code, cballe, except I'm not sure what frmMain.fADO_Connect is. Are you getting an error, or what do you mean when you say you're having problems with it?
|
__________________
Laura
Ita erat quando hic adveni.
|

08-07-2002, 03:11 AM
|
|
|
|
Hi Laura,
thanks vir the reply. The frm.Main.fADO_Connect part is something I got from an Visual Basic book. And it is this part that is giving me problems at the moment. What would you suggest? Should I take this part of code out?
Thanks
|
|

08-07-2002, 04:05 AM
|
 |
Disillusioned Code Poet
Retired Moderator * Guru *
|
|
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
|
|
|
You don't need to take it out, but you need to change it to a valid connection object. That can either be one you set up in code, or if you have an ADODC on your form, it will have a connection property.
|
__________________
Laura
Ita erat quando hic adveni.
|

08-07-2002, 06:23 AM
|
|
|
|
you have to use this line
set .activeconnection = frmMain.fADO_Connect
Because it are objects
|
|

08-08-2002, 02:24 AM
|
|
|
Still having problems
|
Hi there guys,
I have still problems with finally clearing up the problem. Therefore I have added an example project in order to show you all with which problem I still struggle with. Please place the code in a folder C:\aa. Just to make sue that the database is also in the folder when the program wants to access it. You will notice that I have only added a label on the fTest form that displays the test result. This is only an example project, but it must still do the same that it is suppose to do…
One thing that I am still wondering about is: Must there be an Add button on the first (main page)? Because if the user don’t click on the Add button, he can’t enter his information on the Main page.
Hope you guys could help me
Thanks
Regards
C-Power
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|