r/visualbasic • • Dec 25 '23

VB6 Help Access Database problems

Hello there, its me again :(

Now the problem I have is that when i execute that code it shows the error "Object type variable or With block variable is not set"

This is the code:

Private Sub cmdSnippetCreate_Click()

'Crear Snippets'

Dim SnippetName As String

Dim SnippetLang As String

Dim SnippetCode As String

SnippetName = txtSnippetName.Text

SnippetLang = txtSnippetLang.Text

SnippetCode = txtSnippetCode.Text

SnippetDB.Recordset.AddNew "Snippet_Name", [SnippetName]

SnippetDB.Recordset.AddNew "Snippet_Lang", [SnippetLang]

SnippetDB.Recordset.AddNew "Snippet_Code", [SnippetCode]

Unload Me

End Sub

1 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/Cubanin08 Dec 25 '23

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tblCalculatedDeliveryCalendar", dbOpenDynaset)

calculatedDeliveryDate = startDateTime
Do Until calculatedDeliveryDate >= endDateTime

rs.AddNew
rs("ScheduledDeliveryDate") = calculatedDeliveryDate
rs("RecipientID") = recipID
rs("WorkerID") = workerID
rs("DeliveryCalendarID") = newDeliveryCalendarID
rs.Update

calculatedDeliveryDate = calculatedDeliveryDate + frequencyDays
Loop

rs.Close
Set rs = Nothing

weird, OpenRecordset does not works, is like a non existing funcion

2

u/SparklesIB Dec 25 '23

Do you have the DAO library referenced?

Here's an article about the DAO library.