By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,883 Members | 2,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,883 IT Pros & Developers. It's quick & easy.

Getting records from a database from on form to another form

P: 25
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
Share this Question
Share on Google+
2 Replies


P: 8
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

P: 25
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

Post your reply

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