is there anyway i can make my msflexgrid and my textboxes and label boxes.... etc. to the msaccess report table without using a database? i am using vb6... btw... tnx in advance... ^_^
Printable View
is there anyway i can make my msflexgrid and my textboxes and label boxes.... etc. to the msaccess report table without using a database? i am using vb6... btw... tnx in advance... ^_^
You can load the data from the grid into a recordset and use that recordset as the reports datasource.
This example doen't use a grid but it can easily be modified, just cycle thru the grid and add the data to the new recordset.Code:Dim rsU As New ADODB.Recordset, rsG As New ADODB.Recordset
Dim rsR As New ADODB.Recordset
With rsR
' Create Recordset Fields (Columns) here
.Fields.Append "userid", adVarChar, 12
.Fields.Append "name", adVarChar, 50
.Fields.Append "addr1", adVarChar, 50
.Fields.Append "addr2", adVarChar, 50
.Fields.Append "csz", adVarChar, 35
.Fields.Append "acres", adDouble
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open
.Sort = "acres"
End With
rsU.Open "select * from users order by userid", conCnn, adOpenKeyset, adLockReadOnly, adCmdText
With rsU
Do While Not .EOF
rsG.Open "select sum(grossacres) as acres from lots where userid='" + !userid + "' or ownerid='" + !userid + "'", conCnn, adOpenKeyset, adLockReadOnly, adCmdText
rsR.AddNew
rsR!userid = !userid
rsR!Name = !Name
rsR!Addr1 = !Addr1
rsR!Addr2 = !Addr2
rsR!csz = Trim(!City) + ", " + !State + " " + !zip
rsR!acres = IIf(IsNull(rsG!acres), 0, rsG!acres)
rsR.Update
Set rsG = Nothing
.MoveNext
Loop
End With
Set rsU = Nothing
With rptUserowneracreage
Set .DataSource = rsR
.DataMember = rsR.DataMember
.Show vbModal
End With
This "msaccess report table without using a database?" is confusing. If there is no database then how could you set data to an MS Access report? Or did I misunderstood you?
lol, thats exactly my point, how will you do it?!... lately i have been having alot of ideas on how will you do this kind of things... i need only an idea or a hint perhaps.. :D
wes4bt, it is still accessing the database, tnx for the reply guys, i really appreciate it.... but still the answer to my question is not resolved... ^_^
If you load the recordset using your msflexgrid then you don't need to access a database, the code is just an example. hint, hint
OH, can you load a recordset without a destination? what a clever idea, as i think about your hint, it is possible.... i'll try and experiment.... good hint....
Edit: hmmmm.... but your hint up there is still making a table for access, i mean no table as i need only the report.... i still dont get it....
This is what I'm talking about,
There isn't a database necessary for this.Code:Dim rsR As New ADODB.Recordset, i As Integer
With rsR
' Create Recordset Fields (Columns) here
.Fields.Append "somedata", adVarChar, 12
.Fields.Append "moredata", adVarChar, 50
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open
.Sort = "somedata"
End With
With MSFlexGrid
For i = 0 To .Rows - 1
rsR.AddNew
rsR!somedata = .TextMatrix(i, 1)
rsR!moredate = .TextMatrix(i, 2)
rsR.Update
Next i
End With
With DataReport1
Set .DataSource = rsR
.DataMember = rsR.DataMember
.Show vbModal
End With
I'm curious how you plan to fill the MsFlexGrid in the first place.
will try that later. . . tnx. . . :D