-
Jul 29th, 2013, 03:35 AM
#1
Thread Starter
New Member
Displaying Datafield Command1.lname not found.
This is the code which I have written to display data report based on roomno.
But I am getting error as 'Datafield Command1.lname' not found.
Need help to resolved this.
Code:
Private Sub Command1_Click()
Dim conn28 As New ADODB.Connection
Dim str28 As String
Dim Constr28 As String
Set conn28 = New ADODB.Connection
Constr28 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\ShowData.mdb;Persist Security Info=False" 'This is a string which are used to set path and security of access database
conn28.Open Constr28
Dim rs28 As New ADODB.Recordset
rs28.Open "Select name,addr,city,pincode,mobno,chkindate,roomno,roomtype,rentperday,advpaid rom CheckIn where roomno=('" & Text8.Text & "')", conn28, adOpenStatic, adLockReadOnly
With DataReport1
.DataMember = vbNullString
Set .DataSource = rs28
With .Sections("Section1").Controls
.Item("txtlname").DataField = Text1.Text 'lname
.Item("txtaddr").DataField = Text15.Text 'addr
.Item("txtcity").DataField = Text5.Text 'city
.Item("txtpincode").DataField = Text6.Text 'pincode
.Item("txtmobno").DataField = Text4.Text 'mobno
.Item("txtchkindate").DataField = DTPicker1.Value 'chkindate
.Item("txtroomno").DataField = Text8.Text 'roomno
.Item("txtroomtype").DataField = List3.Text 'roomtype
.Item("txtrentperday").DataField = Text9.Text 'rentperday
.Item("txtadvpaid").DataField = txtadvpaid.Text 'advpaid
End With
.Show vbModal
End With
rs28.Close
conn28.Close
End SUb
Last edited by Hack; Jul 29th, 2013 at 06:04 AM.
Reason: Added Code Tags
-
Jul 29th, 2013, 06:05 AM
#2
Re: Displaying Datafield Command1.lname not found.
Welcome to the forums
What line of code is causing the error?
-
Jul 29th, 2013, 06:32 AM
#3
Thread Starter
New Member
Re: Displaying Datafield Command1.lname not found.
.Item("txtlname").DataField = Text1.Text 'lname
in the above line, I am getting error as 'Datafield.command1.lname' is not found.
-
Jul 30th, 2013, 08:34 PM
#4
Re: Displaying Datafield Command1.lname not found.
Did you set the reports datasource property or datamember property during the design? It looks like maybe you used a dataenviroment. If so, remove those property settings.
-
Jul 31st, 2013, 01:36 AM
#5
Thread Starter
New Member
Re: Displaying Datafield Command1.lname not found.
Checked it with removing the properties. But still it is displaying the same error 'Datafield Command1.lname' not found.
-
Jul 31st, 2013, 12:29 PM
#6
Re: Displaying Datafield Command1.lname not found.
Yeah, you also need to remove the datamember property for each textbox on the report. Also, this doesn't seem right,
Code:
Dim rs28 As New ADODB.Recordset
rs28.Open "Select name,addr,city,pincode,mobno,chkindate,roomno,roomtype,rentperday,advpaid rom CheckIn where roomno=('" & Text8.Text & "')", conn28, adOpenStatic, adLockReadOnly
With DataReport1
.DataMember = vbNullString
Set .DataSource = rs28
With .Sections("Section1").Controls
.Item("txtlname").DataField = Text1.Text 'lname
.Item("txtaddr").DataField = Text15.Text 'addr
.Item("txtcity").DataField = Text5.Text 'city
.Item("txtpincode").DataField = Text6.Text 'pincode
.Item("txtmobno").DataField = Text4.Text 'mobno
.Item("txtchkindate").DataField = DTPicker1.Value 'chkindate
.Item("txtroomno").DataField = Text8.Text 'roomno
.Item("txtroomtype").DataField = List3.Text 'roomtype
.Item("txtrentperday").DataField = Text9.Text 'rentperday
.Item("txtadvpaid").DataField = txtadvpaid.Text 'advpaid
End With
.Show vbModal
End With
If you want to use rs28 as your datasource then why are you setting the datafields values to the forms textbox values? Just set the datafield property in the report designer for each report textbox on the report to the corresponding field name in the recordset, like name, address, city ...
btw - I don't see any field in the recordset called "lname", only one called "name"
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
|