I'm not sure exactly what is going on in your program without seeing it.
Have you verified for sure what line is failing? If it is the OpenRecordset
line, it is possible that things are happening too quickly when you are
running the executable as opposed to when you are debugging. Or perhaps the
compiler put some kind of "optimization" in the compiled code.
What I would do in a situation like this is to add a public property to
form2 that matches the property in form1 and get the value out of the
property on form1 and set another property on form2 with the value that you
got out of form1.
strPropertyValue = form1.OfferName
set form1 = nothing
form2.OfferName = strPropertyValue
set form2 = nothing
And in form2 I would have a property procedure rather than a public
Property Let OfferName(ByVal vstrOfferName As String)
mstrOfferName = vstrOfferName
set mydb = OpenDatabase("SALES")
set myrs=mydb.openRecordset(mstrOfferName, dbOpenTable)
> Hello everybody,
> I have a problem here. I tried to create a table in a form with a public
> variable called OfferName. Here is the code:
> set cn = new ADODB.connection
> cn.open "DSN=SALES"
> set rs= new ADODB.Recordset
> rs.ActiveConnection =cn
> rs.Source = "Create table " & OfferName & " (offer_id integer, device_id
> set rs=nothing
> set cn.nothing
> dim mydb as Database
> dim myrs as Recordset
> private sub form_load()
> set mydb = OpenDatabase("SALES")
> set myrs=mydb.openRecordset(form1.OfferName & ",dbOpenTable)
> end sub
> When I run this code a message saying that the path of the file is wrong
> appears BUT when I debbug this code it runs fine...
> Could anybody help me
> Thank you in advance...