Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, VB dude kinda new to development in access 1

Status
Not open for further replies.

x508

Programmer
Jun 26, 2003
396
ZA
Hi.

I am quite new to development in access, although I have been using Access as a backend for my apps for nearly two years now.

The Problem:

How do I, (on a form in access), save whatever is displayed in a combo box, to a specific table.

I want to have the users select fields from a combo which wiil get data from table(that I can do).

The first time they use this functionality, they will see all the values, when clicked, I want ot save the clicked value to a specific table and field. Next time when they use this functionality I want them to only be able to see the value that they clicked the first time???

I can do this in vb in 1 min....please point me in the right direction

thanks

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
if you are talking about creating a new value in a table then you could simply run and APPEND query, or if you mean modifying an already existing value you would use an UPDATE query.

One method is

DoCmd.SetWarnings False 'to avoid the confirm message
DoCmd.RunSQL "Your SQL Here"
DoCmd.SetWarnings True

To learn what SQL you should put in the quotes, create a query and do some SELECT queries. When you are happy with the result set you're getting on running the query, change its type to APPEND or UPDATE and play with it. When you have something that does what you want, switch to SQL view and copy and paste to your heart's content.

Now, your combobox is unbound. That is, you are populating it with data yourself instead of having it connected to a ControlSource and your Form having a RecordSource. It might be easier to do a bound control and then simply disable/enable the bound control in the form's Current or Load events. It's best to disable the control at design-time and enable it when the right conditions are met, as this prevents weird errors where your code does not run correctly from potentially leaving the control enabled. You can set the control's value to whatever you want programatically, too.

I hope this helps!

E
 
Thanks E

One thing

I am used to open recordset objects to work with records.

To insert new records, I use this

Phsuedo Code:

open recordset

rs.AddNew
rs.fields("Whatever") = "new Value"

How do I do this in a SQL statement, I know it's with update or insert....

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
The recordset approach works great. It's just convenient when you can run a single SQL statement

I could answer for you but I'm going to bed now and you should be able to find ample example samples online by searching for

append query access select into

or something similar. Good luck.
 
got it working thanks...the bloody access just won't give me a recordcount

I tried movefirst:movelast at no avail....

In the end I used DCount

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Dim rs as DAO.recordset

set rs = currentdb.openrecordset("tableName", dbopensnpshot) ' or dbopendynaset if you plan to update recordset

'rs.movefirst
'rs.recordcount

rs.close
set rs = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top