Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO code does not work properly 1

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Access 2003 and SQL 2000 Server

1) ADO code does not work. I had the two code below to print
out the two value and they are both the same, yet, it executed the else condition.

MsgBox RecordSet_User_Account!Name
MsgBox Forms!Main_Login!User_Name


If RecordSet_User_Account!Name = Forms!Main_Login!User_Name
Then MsgBox "They are the same"
Else
MsgBox "They are not the same"
End If

2) Could it be that I am using a DAO text box and not an ADO text box ? How do I have an ADO control pallet appear in Access if there is such a thing ?

/////////////////////////////////////////////////

Private Sub User_Login_Using_Table()
Dim cnThisConnect As ADODB.Connection
Dim RecordSet_User_Account As New ADODB.Recordset
Set cnThisConnect = CurrentProject.Connection

RecordSet_User_Account.Open "User_Account", _
cnThisConnect, adOpenKeyset, _
adLockOptimistic, adCmdTable

RecordSet_User_Account.MoveFirst
MsgBox RecordSet_User_Account!Name
MsgBox Me!User_Name
MsgBox RecordSet_User_Account!P

If RecordSet_User_Account!Name = _
Forms!Main_Login!User_Name Then
MsgBox "They are the same"
Else
MsgBox "They are not the same"
End If

RecordSet_User_Account.Close
End Sub
 
Just to be sure:
MsgBox Chr(34) & RecordSet_User_Account!Name & Chr(34) _
& vbCrLf & Chr(34) & Forms!Main_Login!User_Name & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV (MIS). Thank you for your help.

I did as you have sugggested and the value are

"John_Doe "
"John_Doe"

In SQL Server, the field "Name" is declared as Type: nvarchar, Size: 50. Which type should I use so that it won 't automatically add spaces ?
 
I don't know SQL Server, sorry.
A workaround:
If Trim(RecordSet_User_Account!Name) = Trim(Forms!Main_Login!User_Name) Then
MsgBox "They are the same, sort of"
Else
MsgBox "They are not the same"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top