4 Replies - 2652 Views - Last Post: 25 November 2008 - 02:10 PM Rate Topic: -----

#1 el-sid   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 09-October 08

Data member error

Posted 22 November 2008 - 02:16 PM

hi, ive been tryin to get this authentication code to work. anyone help please
Option Explicit
Private Sub cmdcancel_Click()
	Unload Me
End Sub

Public Sub cmdOk_Click()
Dim db_file As String
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

	' Open the database.
	db_file = App.Path
	If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
	db_file = db_file & "examRegistration.mdb"

	' Open a connection.
	Set conn = New ADODB.Connection
	conn.ConnectionString = _
		"Provider=Microsoft.Jet.OLEDB.4.0;" & _
		"Data Source=" & db_file & ";" & _
		"Persist Security Info=False"
	conn.Open

	' Look up the user name/password.
	statement = "SELECT COUNT (*) FROM login WHERE " & _
		"username='" & Replace(txtusername.Text, "'", "''") & "' AND " & _
		"password='" & Replace(txtpassword.Text, "'", "''") & "'"
	Set rs = conn.Execute(statement)

	' See if we got anything.
	If CLng(rs.Fields(0)) < 1 Then
		' There is no match.
		' Do not allow the login.
		Unload Me
		MsgBox "Invalid user name/password."
	Else
		' There is a match.
		' Display the program's main form.
		MDIexams.Show
		Unload Me
	End If

	rs.Close
	conn.Close
End Sub





the error is method or data member not found. its a compile error

Is This A Good Question/Topic? 0
  • +

Replies To: Data member error

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5227
  • View blog
  • Posts: 14,010
  • Joined: 18-April 07

Re: Data member error

Posted 22 November 2008 - 02:39 PM

Ok I don't see any immediate errors with this. So it will have to be related to something I can't see. Make sure that you have included the Microsoft ActiveX Data Objects library 2.0 or greater, that you have your database file in the same folder as your application file, that you have all the controls present for password, username and have a form named MDIExams loaded in your project.

Somewhere in the project you probably have a misspelling or trying to access something that isn't there. Might help to also tell us which line the error is actually occurring on (which one is it flagging yellow)
Was This Post Helpful? 0
  • +
  • -

#3 el-sid   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 09-October 08

Re: Data member error

Posted 22 November 2008 - 09:27 PM

View Postel-sid, on 22 Nov, 2008 - 01:16 PM, said:

hi, ive been tryin to get this authentication code to work. anyone help please
Option Explicit
Private Sub cmdcancel_Click()
	Unload Me
End Sub

Public Sub cmdOk_Click()
Dim db_file As String
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

	' Open the database.
	db_file = App.Path
	If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
	db_file = db_file & "examRegistration.mdb"

	' Open a connection.
	Set conn = New ADODB.Connection
	conn.ConnectionString = _
		"Provider=Microsoft.Jet.OLEDB.4.0;" & _
		"Data Source=" & db_file & ";" & _
		"Persist Security Info=False"
	conn.Open

	' Look up the user name/password.
	statement = "SELECT COUNT (*) FROM login WHERE " & _
		"username='" & Replace(txtusername.Text, "'", "''") & "' AND " & _
		"password='" & Replace(txtpassword.Text, "'", "''") & "'"
	Set rs = conn.Execute(statement)

	' See if we got anything.
	If CLng(rs.Fields(0)) < 1 Then
		' There is no match.
		' Do not allow the login.
		Unload Me
		MsgBox "Invalid user name/password."
	Else
		' There is a match.
		' Display the program's main form.
		MDIexams.Show
		Unload Me
	End If

	rs.Close
	conn.Close
End Sub





the error is method or data member not found. its a compile error



thanks for the reply, i included the from the object references active x data contorl but it still gives me the same error. the yellow line appears at
Public Sub cmdOk_Click()

and a blue line at
"username='" & Replace(txtusername.Text, "'", "''") & "' AND " & _

it only highlights the .Text
Was This Post Helpful? 0
  • +
  • -

#4 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5227
  • View blog
  • Posts: 14,010
  • Joined: 18-April 07

Re: Data member error

Posted 22 November 2008 - 09:54 PM

Are you sure that is what your username box is called? Did you perhaps misspell it? Is it in fact a textbox control? I ask because if txtusername is a label, there is no Text property and hence would cause the problem.

Go to your design view, find the control you labeled txtusername and click on it, see if Text is a property in the properties window.
Was This Post Helpful? 0
  • +
  • -

#5 el-sid   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 09-October 08

Re: Data member error

Posted 25 November 2008 - 02:10 PM

sorry i took a little longer to reply. i really dont know what went wrong but i think there was something wrong with my references - i think i put more than one. i created new project and copy-pasted the code and it worked. thanks for the help. really appreciate it
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1