change recordset

change recordset

Post by Palm » Mon, 14 Jul 2003 12:03:32



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

 
 
 

change recordset

Post by Tim Vic » Mon, 14 Jul 2003 23:12:54


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


 
 
 

change recordset

Post by Palm » Tue, 15 Jul 2003 16:19:24


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

 
 
 

change recordset

Post by Palm » Wed, 16 Jul 2003 18:43:23


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


> 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

 
 
 

1. Can't change .Recordset.AbsolutePosition

When I try to change the .Recordset.AbsolutePosition property of a data
control directly after I started my program, it either does nothing or
says "Invalid argument" (when trying to move to the last item of the
database).
I always have to browse at least e.g. from the 1st to the 2nd item, then
I can change this property correctly.

Can anybody explain why this problem appears and how I could solve it?


--

WEB:  http://home.t-online.de/home/k.stroh
ICQ:  7500377
PGP:  http://home.t-online.de/home/k.stroh/kai_dss.zip

2. OPAL fields going undefined unexpectedly

3. How to Change Recordset Field Name?

4. Usage Of Memory per Process

5. Changing recordset for report

6. Horizontal/Vertical rulers

7. How to change Recordset.LockType ?

8. ssl

9. change recordset 'updatable' property

10. I want change Recordset in Data Environment

11. How to change Recordset type?

12. Cannot update or change recordset i just create

13. open recordset, change connection, update recordset?