|
-
Feb 27th, 2007, 11:45 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Clear field name
I use data control and data grid..
How I can clear the field when the record not found in database?
If Text1.Text = "" Then
MsgBox "Please input your name!", vbExclamation + vbOKOnly, "Peringatan"
Else
Data3.RecordSource = "Select Plot, Area, Owner1, Owner2 from blockC Where Owner1 = '" & StrConv(Text1.Text, vbProperCase) & "' or Owner2= '" & StrConv(Text1.Text, vbProperCase) & "'"
Data3.Refresh
If Data3.Recordset.EOF Then
MsgBox "Nama " & Text1.Text & " not found!.", vbInformation, "Peringatan"
Text1.Text = ""
Else
Data3.Recordset.MoveFirst
End If
End If
'End If
End Sub
-
Feb 28th, 2007, 12:03 AM
#2
Lively Member
Re: Clear field name
Hi,
Why you are using Data Control.. this fuctionality can be applied by coding also by using ODBC connection..
If you want i can post u the code for the same..
Rahul Yadav
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Feb 28th, 2007, 12:07 AM
#3
Thread Starter
Frenzied Member
Re: Clear field name
because I want to list the record in daa grid. Back to the question.. I want to clear the field in the grid...
Thank you
-
Feb 28th, 2007, 12:18 AM
#4
Lively Member
Re: Clear field name
Hi
I have changed code to use ODBC Connection. Try using this code.
Code:
'General Declaration
'Add Reference to "Microsoft Activex DataObjects 2.7" or 2.6,2.5,2.4
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\Temp.mdb;Persist Security Info=False"
rs.CursorLocation = adUseClient
End Sub
Private Sub Command1_Click()
If rs.State = 1 Then rs.Close
rs.Open "Select Plot, Area, Owner1, Owner2 from blockC Where Owner1 = '" & StrConv(Text1.Text, vbProperCase) & "' or Owner2= '" & StrConv(Text1.Text, vbProperCase) & "'", con, adOpenDynamic, adLockReadOnly
DataGrid1.ClearFields
Set DataGrid1.DataSource = rs
End Sub
This will surely help u out...
Last edited by yadavrahul143; Feb 28th, 2007 at 12:19 AM.
Reason: Change in code
Rahul Yadav
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|