Naveed_786 25 Posting Whiz in Training

Thanks it really helped me.

Naveed_786 25 Posting Whiz in Training

Its working fine but i had only one problem now it is counting the records but it shows one extra records i.e

if there is three records in admission table it shows me 4 please help

Naveed_786 25 Posting Whiz in Training

Now it looks like this it gives no error but now nothing is displayed in datagrid and in lblids.

Public Sub LoadData()
Set con = New adodb.Connection
Set rs = New adodb.Recordset
con.Open "Provider =Microsoft.Jet.OLEDB.4.0;Data Source=D:\EA\DB\EA.mdb;"
rs.CursorLocation = adUseClient
      rs.Open "select StudentID,StudentName,Dob,Class from Admission", con, adOpenDynamic, adOpenStatic
      If rs.EOF = True Or rs.BOF = True Then
      lblids.Caption = "0"
      Exit Sub
      Dim i As Integer
      i = 0
      lblids.Caption = i
      For i = 0 To rs.RecordCount
      lblids.Caption = lblids.Caption + 1
      rs.MoveNext
      Next i
      Set DataGrid1.DataSource = rs.DataSource
      DataGrid1.DataMember = rs.DataMember
      End If
End Sub
Naveed_786 25 Posting Whiz in Training

Now my code looks like this but it populates message No such record exists again and again please check this code for bugs

Private Sub txtempno_KeyPress(KeyAscii As Integer)
On Error Resume Next
If KeyAscii = 13 Then
btncalculate.SetFocus
rs2.MoveFirst
While rs2.EOF = False
If Val(txtempno.Text) = rs2.Fields!EmpNo Then
txtsub.Text = rs2.Fields!subjects
txtempname.Text = rs2.Fields!TeacherName
Else
If txtempno.Text = nul Then
MsgBox "Please enter StudentID!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
txtempno.SetFocus
Exit Sub
End If
End If
rs2.MoveNext
Wend
If rs2.EOF = True Or rs2.BOF = True Then
MsgBox "No such record exists!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
End If
End If
End Sub
Naveed_786 25 Posting Whiz in Training

I have made a function Loaddata() and write the code provided by you and call the function on form load but it gives me following error
"Either BOF or EOF is true or the current record has been deleted requested operation requires a current record" So please help me to resolve this problem.

Public Sub LoadData()
Set con = New adodb.Connection
Set rs = New adodb.Recordset
con.Open "Provider =Microsoft.Jet.OLEDB.4.0;Data Source=D:\EA\DB\EA.mdb;"
rs.CursorLocation = adUseClient
rs.Open "select StudentID,StudentName,Dob,Class from Admission", con, adOpenDynamic, adOpenStatic
'While rs.EOF = True Or rs.BOF = True
Dim i As Integer
i = 0
lblids.Caption = i
For i = 0 To rs.RecordCount
lblids.Caption = lblids.Caption + 1
rs.MoveNext
Next i
'Wend
Set DataGrid1.DataSource = rs.DataSource
DataGrid1.DataMember = rs.DataMember
End Sub
Naveed_786 25 Posting Whiz in Training

If you want to create data report in vb then please click on this link to view a complete tutorial on data reports in vb

http://visualbasic.freetutes.com/learn-vb6/lesson22.15.html

Please mark the thread as solved if it helps you.

Naveed_786 25 Posting Whiz in Training

If it is just for login form then why you are using .update and .edit your code is confusing but you can use simply this code for login

On Error GoTo errHandler
Set rs = db.OpenRecordset("SELECT COUNT(*) As Numrows FROM users WHERE LCASE(username) = '" & LCase(txtusername.Text) & "' AND LCASE(pw) = '" & LCase(txtpassword.Text) & "'")
If CInt(rs.Fields!Numrows) > 0 Then
   MsgBox "YOU HAVE SUCCESSFULLY SIGNED IN", vbOKOnly, "EXCELLENT ACADEMY"
   frmMenu.Show
   Unload Me
Else
   MsgBox "LOGIN DENIED PLEASE TRY AGAIN!!"
   txtusername.Text = ""
   txtpassword.Text = ""
   txtusername.SetFocus
End If
Exit Sub
errHandler:
   MsgBox (Err.Description)
AndreRet commented: Nicely done. +4
Naveed_786 25 Posting Whiz in Training

Hi

I want to display content of text boxes in its tool tip how it can be done.

Thanks

Just Get the properties of textbox then find the property tooltip text then type some text with you want to display at run time

Please download and view the attachment below

Please mark the thread as solved if it helps you.

Naveed_786 25 Posting Whiz in Training

How can i count the no of records fetched in datagrid from admission table and how to show these no of records in a label i.e

Total No of records = 20

Please help

Naveed_786 25 Posting Whiz in Training

I want to check if record does not in database it should populate message that user doesn't exists in database. i want to adjust do while loop or some thing else to perform this operation please help.

Private Sub txtempno_KeyPress(KeyAscii As Integer)
      On Error Resume Next
      If KeyAscii = 13 Then
      btncalculate.SetFocus
      rs2.MoveFirst
      While rs2.EOF = False
      If Val(txtempno.Text) = rs2.Fields!EmpNo Then
      txtsub.Text = rs2.Fields!subjects
      txtempname.Text = rs2.Fields!TeacherName
      Else
      If txtempno.Text = nul Then
      MsgBox "Please enter StudentID!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
      txtempno.SetFocus
      Exit Sub
      End If
      End If
      rs2.MoveNext
      Wend
      End If
      End Sub
Naveed_786 25 Posting Whiz in Training

How would i check record already exists??

Naveed_786 25 Posting Whiz in Training

Dear all,
Please help me i want to check record already exists in database please modify this code please help

Private Sub txtempno_KeyPress(KeyAscii As Integer)
On Error Resume Next
If KeyAscii = 13 Then
btncalculate.SetFocus
rs2.MoveFirst
While rs2.EOF = False
If Val(txtempno.Text) = rs2.Fields!EmpNo Then
txtsub.Text = rs2.Fields!subjects
txtempname.Text = rs2.Fields!TeacherName
Else
If txtempno.Text = nul Then
MsgBox "Please enter StudentID!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
txtempno.SetFocus
Exit Sub
End If
End If
rs2.MoveNext
Wend
End If
End Sub
Naveed_786 25 Posting Whiz in Training

Thanks alit it realy helped me

Naveed_786 25 Posting Whiz in Training

Yes

Naveed_786 25 Posting Whiz in Training

No its not fetching data from database

Naveed_786 25 Posting Whiz in Training

Yes all objects are present on my form this line producing error

Set DataGrid1.DataSource = admissionssql
Naveed_786 25 Posting Whiz in Training

I am using this code to fetch all records in datagrid but it didn't work for me gives error object required please help.

Dim db As Database
Dim rs As Recordset
Dim admissionssql As String
Private Sub Form_Load()
Set db = OpenDatabase("D:\EA\DB\EA.mdb")
Set rs = db.OpenRecordset("Admission")
admissionsql = "SELECT  StudentID,StudentName" _
      & " FROM admission " _
      & "Order by StudentID"
   Set DataGrid1.DataSource = admissionssql
End Sub
Naveed_786 25 Posting Whiz in Training

Thanks for your reply i didn't want to use data tool loke adodc or data1 i want to control it progmatically please help

Naveed_786 25 Posting Whiz in Training

Hi all,

1. I want to know how to add a data grid in vb 6 form?
2. And how to fetch all records in data grid

please help

Thanks in advance for help.

Naveed_786 25 Posting Whiz in Training

Its showing the date in textbox but when i click on calculate button it gives message invalid use of null but when i pass dates manually and click on calculate button then it perform calculation

Naveed_786 25 Posting Whiz in Training

How should i call clean up method sorry i didn't understand??

Naveed_786 25 Posting Whiz in Training

I have tried both but didn't help me

Naveed_786 25 Posting Whiz in Training

I have a problem with date and time picker when i select the date from dtpicker1 then txtdate1 gets the value but when i debug it shows txtdate1 = "" why please help

Private Sub DTPicker1_CloseUp()
txtdate1.Text = DTPicker1.Value
DTPicker1.Refresh
End Sub
Naveed_786 25 Posting Whiz in Training

Hi guys,

1.Can anyone help me how should i design my first web page in asp.net using C#
2.which should have 4textboxes and 2buttons
3.how can i connect the asp.net with sql server 2008
4.how can i insert my first record in sql server db please please help then i would carry on my self.

Thanks in advance for your help.

Naveed_786 25 Posting Whiz in Training

I am using this peace of code but still no luc please help

On Error Resume Next
rs1.MoveFirst
    Set rs1 = db.OpenRecordset("SELECT StudentName FROM Admission WHERE StudentName LIKE '" & txtsname & "%'")
Naveed_786 25 Posting Whiz in Training

Ok thanks

Naveed_786 25 Posting Whiz in Training

Ok now i have made some changes can you guide me how much more changes should i made and where should i made changes

CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowPrinter
If Err.Number = 32755 Then
Exit Sub
End If
On Error GoTo 0
If CommonDialog1.Orientation = cdlLandscape Then
Printer.Orientation = cdlLandscape
End If
Dim YPos As Long
ClearPrintoutArea
' Position title on the page
PRN.CurrentX = 30: PRN.CurrentY = 15
' Set title font
Dim fnt As New StdFont
fnt.Name = "Verdana": fnt.Size = 14: fnt.Bold = True
Set PRN.Font = fnt
PRN.Print "Excellent Acadmy"
PRN.Print
' Use smaller size for text
fnt.Size = 12: fnt.Bold = False
Set PRN.Font = fnt
PRN.Print "txtstudentid.Text " & "txtstudentname " & "txtfathername" & _
"txtdob" & "txtclass" & "txtsubjects" & "txtmedium" & "txtfee" & _
"txttotalsubjects" & "txtadmissiondate"
PRN.Print
'PRN.Print "However, every time you call the Print method, " & _
"the text start at the far left edge of the form on the following line."
'PRN.Print
'PRN.Print
' Another font font for formatted text
fnt.Size = 10: fnt.Italic = True
Set PRN.Font = fnt
' Set the left margin.
' No need to set the vertical coordinate,
' because each call to the Print method
' advances to the following line
PRN.CurrentX = 20
PRN.Print "Print and preview formatted text. "
PRN.CurrentX = 20
PRN.Print "If the text printed with a single call to the Print method exceeds "
PRN.CurrentX = 20
PRN.Print "the width of the form, …
Naveed_786 25 Posting Whiz in Training

Ok see this the text which i want to print

Printer.Print txtstudentid.Text
Printer.Print txtstudentname
Printer.Print txtfathername
Printer.Print txtdob
Printer.Print txtclass
Printer.Print txtsubjects
Printer.Print txtmedium
Printer.Print txtfee
Printer.Print txttotalsubjects
Printer.Print txtadmissiondate
Printer.Print Label1
Printer.Print Label2
Printer.Print Label3
Printer.Print Label4
Printer.Print Label5
Printer.Print Label6
Printer.Print Label7
Printer.Print Label8
Printer.Print Label9
Printer.Print Label10
Printer.Print Label11
Printer.Print Label12

Can you modify it for me please

Naveed_786 25 Posting Whiz in Training

Also have you added run time of crystal reports in your setup

Naveed_786 25 Posting Whiz in Training

Please view this link

http://www.codeproject.com/KB/vb/InsertUpdateDeleteSearch.aspx

Mark the thread as solved if it helps you.

Naveed_786 25 Posting Whiz in Training

Ok its not printing the contents of textboxes it just prints this text

"Print and preview formatted text.
If the text printed with a single call to the print method exceeds
the width of the form, the text isn't wrapped automatically.

What is the problem with it.

Naveed_786 25 Posting Whiz in Training

It is giving me error on this line

Now giving me error "User defiend variable not defiend"
YPos = PRN.CurrentY
Naveed_786 25 Posting Whiz in Training

Yes it would read records from database

Naveed_786 25 Posting Whiz in Training

Sorry
when i press 'a' then there should be a drop down list having all records strating from 'a'

Sorry if you mind exteamly sorry

Naveed_786 25 Posting Whiz in Training

i have saw these examples but it does not meet my requirment please provide my some sample code

Naveed_786 25 Posting Whiz in Training

You mean i should have two Command button one is for this peace of code

Private Sub cmdPrinter_Click()
Set PRN = PrinterPRN.ScaleMode = 6
CreateSimplePrintoutPrinter.EndDocEnd Sub

and second is for


Private Sub cmdPrnForm_Click()Set PRN = frmPrintoutPRN.ScaleMode = 6CreateSimplePrintoutEnd SubPrivate Sub cmdPrinter_Click()
Set PRN = Printer
PRN.ScaleMode = 6
CreateSimplePrintout
Printer.EndDoc
End Sub

Private Sub cmdPrnForm_Click()
Set PRN = frmPrintout
PRN.ScaleMode = 6
CreateSimplePrintout
End Sub

i think the both have same function

Naveed_786 25 Posting Whiz in Training

Now giving me error "User defiend variable not defiend"
YPos = PRN.CurrentY

Naveed_786 25 Posting Whiz in Training

This line of code what is cmdprnform

Private Sub cmdPrnForm_Click()
Naveed_786 25 Posting Whiz in Training

This peace of code have some bugs please check it for errors

I have observed some like

1. CommonDialog1 is not defined
2. frmPrintout is not defined
3. Also these two peaces of code confusing me

Private Sub cmdPrinter_Click()
Set PRN = Printer
PRN.ScaleMode = 6
CreateSimplePrintout
Printer.EndDoc
End Sub

Private Sub cmdPrnForm_Click()
Set PRN = frmPrintout
PRN.ScaleMode = 6
CreateSimplePrintout
End Sub
Naveed_786 25 Posting Whiz in Training

How can we auto complete a textbox in VB 6 please help

Naveed_786 25 Posting Whiz in Training

I am using this method to take print of data peresent in textboxes but it prints on top left corner i want to take print in a sequence and distance as it apears on form also want to increase font size waht should i do please help me.

Printer.Print txtstudentid.Text
Printer.Print txtstudentname
Printer.Print txtfathername
Printer.Print txtdob
Printer.Print txtclass
Printer.Print txtsubjects
Printer.Print txtmedium
Printer.Print txtfee
Printer.Print txttotalsubjects
Printer.Print txtadmission
Printer.EndDoc
Naveed_786 25 Posting Whiz in Training

I have resolved it thanks for yuor help

AndreRet commented: For not giving up to find a solution. +4
Naveed_786 25 Posting Whiz in Training

Ok i would try and let you know if could have any problem thanksfor your reply

Naveed_786 25 Posting Whiz in Training

Ok can you provide me sample coding for login a user by checking user exists in users table i have tried but no luck

i am trying some thing like this

dim db as database
dim rs as recordset


on form load i am connecting with database like this
my connecting string here and
set rs = db.openrecordset("Users")

Then i used this coding on btnlogin

select query here

but i didn't successed i please help me waiting for you reply

Naveed_786 25 Posting Whiz in Training

within my application

Naveed_786 25 Posting Whiz in Training

Please use installationshield

Naveed_786 25 Posting Whiz in Training

Please start new thread.....

Naveed_786 25 Posting Whiz in Training

Can any one tell me how can i make privileges for user to restrict them and only administrator have all rights.

Please help me
Thanks in advance.

Naveed_786 25 Posting Whiz in Training

Hi dear,

I have resolved the problem by using this code

On Error Resume Next
If KeyAscii = 13 Then
txtstudentname.SetFocus
rs.MoveFirst
While rs.EOF = False
If Val(txtstudentid.Text) = rs.Fields!StudentID Then
MsgBox "RECORD ALREADY EXISTS!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
txtstudentid.SetFocus
Exit Sub
Else
If txtstudentid = nul Then
MsgBox "Please enter StudentID!", vbOKOnly + vbInformation, "EXCELLENT ACADMY"
txtstudentid.SetFocus
Exit Sub
End If
End If
rs.MoveNext
Wend
End If

Thanks alot for your help.

Naveed_786 25 Posting Whiz in Training

I am using this code on keypress event of txtstudentid please help me how would i check here that record already exists. when i use this it populates message when i click on the textbox

Private Sub txtstudentid_KeyPress(KeyAscii As Integer)
if rs.recordcount > 0 then
msgbox "Record already exist.",vbexclamation
exit sub
If KeyAscii = 13 Then
txtstudentname.SetFocus
If txtstudentid.Text = nul Then
MsgBox "Field Must Be Entered", vbOKOnly + vbExclamation, "EXCELLENT ACADMY"
txtstudentid.SetFocus
End If
End If
End if
End Sub