473,479 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting records from a database from on form to another form

25 New Member
Hi Good guys

I am a newbie in VB 6.0. I want to retrieve records from a database. I want to use three fields from the database as a key to retrieve a record and post this record details to a second form.

This what i have for the time being:


Expand|Select|Wrap|Line Numbers
  1. Public Sub cmdCheckRest_Click()
  2.  
  3. Dim Key_Fld As String
  4. Dim Exam_Sr As String
  5. Dim Exam_Yr As String
  6. Dim Cand_No As String
  7. Dim cbosch As String
  8. Dim May_June As String
  9. Dim Nov_Dec As String
  10. Dim i As Integer
  11.  
  12. If rs.RecordCount = o Then Exit Sub
  13.  
  14. rs.MoveFirst
  15.  
  16. For i = 1 To rs.RecordCount ' Read all the records from database
  17. Exam_Sr = rs("Exam Series")
  18. Exam_Yr = rs("Exam Year")
  19. cbosch = rs("Cent No")
  20. Cand_No = rs("Index No")
  21. Cand_Name = rs("Cand Name")
  22. Sex = rs("Sex")
  23.  
  24.  
  25. 'Exam Serie validation
  26.  
  27. If Exam_Sr = "" Then
  28.         MsgBox "Please supply the Exam Series to search for candidate result", vbOKOnly, "Cannot Find Result"
  29.      Else
  30.   Exam_Sr.SetFocus
  31.      ElseIf Exam_Yr.Text = "" Then
  32.         MsgBox "You have not entered the Exam_Yr.", vbOKOnly
  33.    End If
  34.  
  35.   Key_Fld = (Exam_Sr & Exam_Yr & Cand_No)
  36. ' (this is what i want to use as a key from the database)
  37.  
  38.  rs.MoveNext ' read next record
  39. Next i
  40.  
  41.     ' Show a modal form named frmcandResult.
  42.  
  43.      frmCandResult.Key_Fld1.Caption = Exam_Serie
  44.      frmCandResult.Show vbModal, Me 
  45. ' (This is where want to send the results of the search)
Thank you very much for your help.
Sep 20 '07 #1
2 1331
Ack Programming
8 New Member
I Would declare my key_fld as Public and on the form_load Event Let The Information be set to the key_fld1.caption Property
Sep 20 '07 #2
gilsygirl
25 New Member
I Would declare my key_fld as Public and on the form_load Event Let The Information be set to the key_fld1.caption Property
Thanks for the reply. My problem is combining the fields

Code :vb

Exam_Sr
Exam_Yr
Cent_No
Cand_No

together to form a search key to retrieve records from the database.

Thanks
Sep 28 '07 #3

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

Similar topics

15
7936
by: U N Me | last post by:
I have a continuous form that lists records from a query. One of the columns is an amount field, In the footer of the form I place a text box that displays the total (sum) of the amount. The...
28
4014
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
6
2495
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
4
1991
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
11
2225
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
3
3100
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
1
1596
by: sparks | last post by:
I have a form/table with an autoid it is linked to a table/form with and ID as a 1 to many. Under this form/table I need another table with many records for each on of the many in the previous...
11
3646
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
2
4431
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
0
7027
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.