Extracting a row from a table using VB in Access 97 
Author Message
 Extracting a row from a table using VB in Access 97

Hi all,

I'm hurriedly learning some VBA while making a database for work.  Could you
help me with this deceptively simple problem?

I have a table called "Type" which contains two columns, TypeId and
TypeName.  Currently the rows in them are:
TypeID                    TypeName
0                              New
1                              Maintenance
2                              Other

On my form there is a combo box called ProjectTypeComboBox.
I want to use a statement similar to...

If ProjectTypeComboBox = (SELECT TypeId FROM Type WHERE TypeName =
"Maintenance") THEN ...

... to avoid hard-coding the value "1" into the IF statement.

So far all I can see is that some sort of ODBC or Jet linking is required.
Shouldn't there be an easier way, since everything I'm using is in the one
database?


Thanks for your time
~~simon



Sun, 11 Aug 2002 03:00:00 GMT  
 Extracting a row from a table using VB in Access 97
Hi Simon--

Have a look at the DLookup function. It'll look something like this:

If ProjectTypeComboBox = DLookup("TypeID,"Type", "TypeName = 'Maintenance'"
THEN

--
Robert R. Thele


[Remove NoSpam_ to reply via E-mail]

Quote:
> Hi all,

> I'm hurriedly learning some VBA while making a database for work.  Could
you
> help me with this deceptively simple problem?

> I have a table called "Type" which contains two columns, TypeId and
> TypeName.  Currently the rows in them are:
> TypeID                    TypeName
> 0                              New
> 1                              Maintenance
> 2                              Other

> On my form there is a combo box called ProjectTypeComboBox.
> I want to use a statement similar to...

> If ProjectTypeComboBox = (SELECT TypeId FROM Type WHERE TypeName =
> "Maintenance") THEN ...

> ... to avoid hard-coding the value "1" into the IF statement.

> So far all I can see is that some sort of ODBC or Jet linking is required.
> Shouldn't there be an easier way, since everything I'm using is in the one
> database?


> Thanks for your time
> ~~simon



Sun, 11 Aug 2002 03:00:00 GMT  
 Extracting a row from a table using VB in Access 97
Thanks Robert, it worked well.

~~simon


Quote:
> Hi Simon--

> Have a look at the DLookup function. It'll look something like this:

> If ProjectTypeComboBox = DLookup("TypeID,"Type", "TypeName =
'Maintenance'"
> THEN

> --
> Robert R. Thele


> [Remove NoSpam_ to reply via E-mail]


> > Hi all,

> > I'm hurriedly learning some VBA while making a database for work.  Could
> you
> > help me with this deceptively simple problem?

> > I have a table called "Type" which contains two columns, TypeId and
> > TypeName.  Currently the rows in them are:
> > TypeID                    TypeName
> > 0                              New
> > 1                              Maintenance
> > 2                              Other

> > On my form there is a combo box called ProjectTypeComboBox.
> > I want to use a statement similar to...

> > If ProjectTypeComboBox = (SELECT TypeId FROM Type WHERE TypeName =
> > "Maintenance") THEN ...

> > ... to avoid hard-coding the value "1" into the IF statement.

> > So far all I can see is that some sort of ODBC or Jet linking is
required.
> > Shouldn't there be an easier way, since everything I'm using is in the
one
> > database?


> > Thanks for your time
> > ~~simon



Tue, 13 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using VB to convert Access 97 table datatypes

2. Need HaveDeleting Rows From an Access Table Using VB.Net Front End

3. Linked table in Access 97 using VBA code ????

4. Opening second recordset on the same table using DAO in Access '97

5. filtering records, using dbgrid linked to an access 97 table

6. Relinking Access 97 tables using ADO

7. Relinking Access 97 tables using ADO...

8. ADO using 3.51 with Links to Access 97 tables

9. Help: convert access 2.0 to access 97 using VB 5.0

10. vba code to copy table from access 97 to excel 97

11. Saving a Word 97 Document in a Access 97 table

12. Can you pass a table to Word 97 from Access 97

 

 
Powered by phpBB® Forum Software