change recordset 
Author Message
 change recordset

Hello all,
I have a program that connects to a database and will need to access
different recordsets depending on what the user types into a textbox. In the
example below I am only using one recordset called "January." I need to be
able to have a user select a different recordset call February perhaps. Can
anyone help? Example listed below...

Public Sub Setdlinfo()
    Set Db = OpenDatabase(dlDBname)
    SQL1 = "Select max(ID)as [Number] from January"
    Set Rs = Db.OpenRecordset(SQL1)
    If IsNull(Rs!Number) Then
        frmmain.lblid = 1
    Else
        frmmain.lblid = Val(Rs!Number) + 1
    End If
    frmmain.cmdEnter.Caption = "Enter Information"
    frmmain.cmdEnter.Refresh
End Sub



Thu, 29 Dec 2005 11:03:32 GMT
 change recordset

I'm still kinda new at this but why couldn't you pass in the month that you
want from a text bax and cat it to your SQL statement? somthing like this:

QueryString = Select max(ID)as [Number]from  '" &
Trim(FrmDialog.TxtDialog.Text) & "'"

 I've used this code and it works fine you just need to watch the quotes
QueryString = "Select * from aircraftDB where tail_Number =  '" &
Trim(FrmDialog.TxtDialog.Text) & "'"

Just a thought let me know what you think


Quote:
> Hello all,
> I have a program that connects to a database and will need to access
> different recordsets depending on what the user types into a textbox. In
the
> example below I am only using one recordset called "January." I need to be
> able to have a user select a different recordset call February perhaps.
Can
> anyone help? Example listed below...

> Public Sub Setdlinfo()
>     Set Db = OpenDatabase(dlDBname)
>     SQL1 = "Select max(ID)as [Number] from January"
>     Set Rs = Db.OpenRecordset(SQL1)
>     If IsNull(Rs!Number) Then
>         frmmain.lblid = 1
>     Else
>         frmmain.lblid = Val(Rs!Number) + 1
>     End If
>     frmmain.cmdEnter.Caption = "Enter Information"
>     frmmain.cmdEnter.Refresh
> End Sub



Thu, 29 Dec 2005 22:12:54 GMT
 change recordset

Well, Now i'm getting "syntax error in query. Incomplete query clause"

This is what I have...

Public Sub Setdlinfo()

    Set Db = OpenDatabase(dlDBname)
    SQL1 = "Select max(ID) as [Number] from '" &
trim(frmdialog.txtdialog.Text) & "'"

    Set Rs = Db.OpenRecordset(SQL1)
    If IsNull(Rs!Number) Then
        frmmain.lblid = 1
    Else
        frmmain.lblid = Val(Rs!Number) + 1
    End If
    frmmain.cmdEnter.Caption = "Enter Information"
    frmmain.cmdEnter.Refresh
End Sub


Quote:
> I'm still kinda new at this but why couldn't you pass in the month that
you
> want from a text bax and cat it to your SQL statement? somthing like this:

> QueryString = Select max(ID)as [Number]from  '" &
> Trim(FrmDialog.TxtDialog.Text) & "'"

>  I've used this code and it works fine you just need to watch the quotes
> QueryString = "Select * from aircraftDB where tail_Number =  '" &
> Trim(FrmDialog.TxtDialog.Text) & "'"

> Just a thought let me know what you think



> > Hello all,
> > I have a program that connects to a database and will need to access
> > different recordsets depending on what the user types into a textbox. In
> the
> > example below I am only using one recordset called "January." I need to
be
> > able to have a user select a different recordset call February perhaps.
> Can
> > anyone help? Example listed below...

> > Public Sub Setdlinfo()
> >     Set Db = OpenDatabase(dlDBname)
> >     SQL1 = "Select max(ID)as [Number] from January"
> >     Set Rs = Db.OpenRecordset(SQL1)
> >     If IsNull(Rs!Number) Then
> >         frmmain.lblid = 1
> >     Else
> >         frmmain.lblid = Val(Rs!Number) + 1
> >     End If
> >     frmmain.cmdEnter.Caption = "Enter Information"
> >     frmmain.cmdEnter.Refresh
> > End Sub



Fri, 30 Dec 2005 15:19:24 GMT
 change recordset
Tim,

I couldn't have done it without you man... thanks!

Here is what I ended up with...

Public Sub Setdlinfo()

frmyear.lblyear.Caption = year(Now)

recset = Trim(frmyear.lblyear.Caption)

Set Db = OpenDatabase(dlDBname)

SQL1 = "Select max(ID) as [Number] from " & recset

Set Rs = Db.OpenRecordset(SQL1)

If IsNull(Rs!Number) Then

frmmain.lblid = 1

Else

frmmain.lblid = Val(Rs!Number) + 1

End If

frmmain.cmdEnter.Caption = "Enter Information"

frmmain.cmdEnter.Refresh

End Sub


Quote:

> Well, Now i'm getting "syntax error in query. Incomplete query clause"

> This is what I have...

> Public Sub Setdlinfo()

>     Set Db = OpenDatabase(dlDBname)
>     SQL1 = "Select max(ID) as [Number] from '" &
> trim(frmdialog.txtdialog.Text) & "'"

>     Set Rs = Db.OpenRecordset(SQL1)
>     If IsNull(Rs!Number) Then
>         frmmain.lblid = 1
>     Else
>         frmmain.lblid = Val(Rs!Number) + 1
>     End If
>     frmmain.cmdEnter.Caption = "Enter Information"
>     frmmain.cmdEnter.Refresh
> End Sub



> > I'm still kinda new at this but why couldn't you pass in the month that
> you
> > want from a text bax and cat it to your SQL statement? somthing like
this:

> > QueryString = Select max(ID)as [Number]from  '" &
> > Trim(FrmDialog.TxtDialog.Text) & "'"

> >  I've used this code and it works fine you just need to watch the quotes
> > QueryString = "Select * from aircraftDB where tail_Number =  '" &
> > Trim(FrmDialog.TxtDialog.Text) & "'"

> > Just a thought let me know what you think



> > > Hello all,
> > > I have a program that connects to a database and will need to access
> > > different recordsets depending on what the user types into a textbox.
In
> > the
> > > example below I am only using one recordset called "January." I need
to
> be
> > > able to have a user select a different recordset call February
perhaps.
> > Can
> > > anyone help? Example listed below...

> > > Public Sub Setdlinfo()
> > >     Set Db = OpenDatabase(dlDBname)
> > >     SQL1 = "Select max(ID)as [Number] from January"
> > >     Set Rs = Db.OpenRecordset(SQL1)
> > >     If IsNull(Rs!Number) Then
> > >         frmmain.lblid = 1
> > >     Else
> > >         frmmain.lblid = Val(Rs!Number) + 1
> > >     End If
> > >     frmmain.cmdEnter.Caption = "Enter Information"
> > >     frmmain.cmdEnter.Refresh
> > > End Sub



Sat, 31 Dec 2005 17:43:23 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Can't change .Recordset.AbsolutePosition

2. How to Change Recordset Field Name?

3. Changing recordset for report

4. How to change Recordset.LockType ?

5. change recordset 'updatable' property

6. I want change Recordset in Data Environment

7. How to change Recordset type?

8. Cannot update or change recordset i just create

9. open recordset, change connection, update recordset?

10. How to change ADO recordset retrieved from Oracle into new recordset

11. recordset record position change upon the Datacombo change...

12. changing an ADO recordset source problem


 
Powered by phpBB® Forum Software