Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Problem with "Recordset.Edit" on a "DataEntry" form in Ace..

 
   Database Forums (Home) -> Visual Basic -> DAO RSS
Next:  SQL Server 2000 Analysis Services - Editing Cubes  
Author Message
Russell Potter

External


Since: Jun 10, 2007
Posts: 6



(Msg. 1) Posted: Fri Jul 20, 2007 8:56 am
Post subject: Problem with "Recordset.Edit" on a "DataEntry" form in Acesss 2000...
Archived from groups: microsoft>public>vb>database>dao (more info?)

I have a form (called "MainForm") whose
"DataEntry" property is set to "true" and
whose "RecordSource" property is set to
table "MainTable", which itself contains
two string fields naned "main1" and
"main2", as well as six other string fields
named "item1" through to "item6"

"MainForm" contains a text box
control named "txtMain" whose
"controlSource" property is
set to "mainfld", as well as a sub-form
named "subf", whose "DataEntry"
property is also set to "true", which
is set to "Continuous Forms" display mode,
whose "RecordSource" is set to another
table named "SubTable", (which has a
string field named "subfld"), and
which has a "text box" control named
"txtSub" whose "ControlSource" property
is set to "subfld"

I want to set up a eituation in which
"MainForm" (being in "DataEntry" mode)
creates a "MainTable" row by the
entry of data into "txtMain" as well
as the creation of a row of "SubTable"
for each entry of data into "txtSub" (Since
that form is also in "DataEntry"
mode) ...

All quite traight-forward so far,
I hear you thinking, all handled
quite easily by the Access GUI: the
extra twist, however, is that, for
the first 6 rows created in
"SubTable" (by the entry of data
into the corresponding "txtSub" text
box), I also want the contents of
rach "txtSub" text-box to be
copied to the "item<n>" fields (of
"MainForm")

Here's the VB code I creaated in
my attempt to sccomplish this task:

> sub add_items()
>
> Dim i as Integer = 1
> Dim rmain As DAO.Recordset = _
> CurrentDB.OpenRecordset("MainTable")
>
> ' rget recordset behind sub-form of "MainForm"
> Dim rsub As DAO.Recordset = _
> Forms!MainForm!subf.Form.RecordsetClone
>
> rsub.MoveFirst
>
> ' cycle through each record in sub-form
> while i < 6 and not rsub.EOF
>
> rmain.Edit 'preare for changes to "rmain"
>
> ' set "MainTable"'s "item<n>" field
> ' from current sub-form text box
> rmain("item" & i) = rsub("subfld")
> rmain.Update ' commit changes
>
> i = i + 1
> rsub.MoveNext
>
> wend
>
> end sub

My thinking in the design of the
above code was that, since a row
of "MainForm" will have already
been craated by entry of data
into "txtMain"(since "MainForm" is
in "DataEntry" mode), then the VB
code merely needs to "Edit" the
row to set the "item<n>" fields of
that created row ...

Trouble is, after this code is run
I find that, while a erow of
"MainTable" is created as
expected, and the contents of the
"mainfld" field was set
correctly from the "txtMain" text
box, I found all of the "item<n>"
fields were set instead to "null"

Does anyone know what I'm doing
wrong and how I might be able to
fix this code?

Thanks,
Russell

 >> Stay informed about: Problem with ""Recordset.Edit"" on a ""DataEntry"" form in Ace.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Finding out the added record in a "DataEntry" form ... - In a form whose "DataEntry" property is "true" and which has had data`entered into it, thereby creating a new record in the form's underlying recordset, is there any way, in VB, of finding out the identity of that new-created record (...

Problem with Data1.recordset.AddNew - Hi All I have a Access97 Database and if I delete all the records compat the database when I use AddNew I get an error message Runtime Error '3426': This action was cancelled by an arseociated object. and highlights the Data1.recodset.AddNew line in..

dao recordset error trapping - I have a dao recordset which I update with the following code: With rsOrderShip .Edit !CustCode = frmOrders.txtSTCustCode.Text !stcustname = frmOrders.txtSTCustName.Text !staddress1 = frmOrders.txtSTAddress1.Text ....

Error 3167 recordset is delete - Hello, ich habe in verschiedenen Newsgroups gesucht aber keine Lösung zu dem folgenden Problem gefunden. Zwei Personen arbeiten gemeinsam mit einem VB6-Programm an einer ACCESS 2000 Datenbank Der Zugriff von VB auf ACCESS erfolgt mit DAO 3.60. Eine de...

Deleting records from DAO recordset - [posted earlier in other group] Hi All, I'm using the following code to delete one or more records from a DAO recordset. The code is working but I was wondering if I need to Update the recordset with: rsDel.Update? Public Function DelRecs(Lstview As....
   Database Forums (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]