Reputation: 388
I want to show the results of a call to a webservice (several rows) in ms-Access. To do this I created a form with the defaultView = 1 (= continuous form).
Now I wonder if I can use show results from the webservice directly in my form. This means without creating a table which I then select with the recordsource-property.
Is there a way to show data a continuous-form in MS-Access without using a table?
I tried to set the recordset by myself like this:
Private Sub Form_Load()
Set m_Dataset = CurrentDb.OpenRecordset("Test", RecordsetTypeEnum.dbOpenDynamic)
Call m_Dataset.AddNew
m_Dataset("OutOfThinAir") = "Hallo"
Set Me.Recordset = m_Dataset
End Sub
But OpenRecordset raises the error "invalid argument".
I also thought of setting the recordsource to a select statement without using a table name (In oracle this would be "Select ... from dual") but I did not find a working statement. "SELECT 1 from dual;" does definitely not work.
Upvotes: 1
Views: 334
Reputation: 388
With the help of Erik A I I figured out a solution which works:
Private Sub Form_Load()
Dim rstADO As ADODB.Recordset
Set rstADO = New ADODB.Recordset
rstADO.Fields.Append "OutOfThinAir", adVarChar, 100, adFldMayBeNull
rstADO.LockType = adLockOptimistic
rstADO.Open
rstADO.Addnew
rstADO.Fields("OutOfThinAir") = "Hello"
rstADO.Update
rstADO.Addnew
rstADO.Fields("OutOfThinAir") = "Du"
rstADO.Update
Set Me.Recordset = rstADO
End Sub
Btw I had to add "Microsoft ActiveX Data Objects 6.1 Library" as a reference in order to use the constants and "ADODB.Recordset" as a variabletype.
Upvotes: 1
Reputation: 32642
Yes, but you'd need to use an ADODB recordset, not a DAO one.
E.g.
Dim m_Dataset As New ADODB.Recordset
m_Dataset.Fields.Append "OutOfThinAir",adVarWChar, 6, adFldUpdatable
m_Dataset.Open
m_Dataset.AddNew 'No call!
m_Dataset("OutOfThinAir") = "Hallo"
Set Me.Recordset = m_Dataset
Upvotes: 3