data entry in form

G

Garry

I am very puzzled. I am creating a database (access 2000, DAO) and in one
case I have to automatically create a new record in a table (tblReturn) that
is not “attached†to the current form. In VBA I open a recordset based on
tblReturn, add a new record, update the table
set recordset = db.openrecordset(“tblReturnâ€)
rec.addnew
--- add data to the recordset
rec.update
rec.close

All works, the new record appears in the form.
One field in the table must be entered by the user, so I open a new form
(data source is tblReturn), with focus set on the control bound to the field
that needs to be entered, with WindowMode:=acDialog, so when the new form is
closed, I go back to the first form. The forms OnCurrent event moves to the
last record using the DoCmd.GoToRec acLast. The control that accepts input
has enabled=Yes, locked=No (all other controls on the form have enabled=no,
locked=yes – so the user doesn’t accidently change something). When the form
opens, it shows the last record (entered in VBA), but the problem is that the
control will not accept any data, it looks like the control has enabled =
Yes, and locked = Yes, i.e. cursor is in the control but you cannot change
the default value.
If I delete control source for the control so it is unbound, I can enter data.

The new form (tblReturn) is based on an another existing form used by the
user to enter all data into the table manually, and it works fine. The only
form property I changed was the OnCurrent event to go to the last record.

Does anyone have any ideas?? -- Thanks, Garry Gross
 
R

RuralGuy

The OnCurrent event is a poor choice to move the record pointer which creates
another OnCurrent event! I would use the OnLoad event.

I am very puzzled. I am creating a database (access 2000, DAO) and in one
case I have to automatically create a new record in a table (tblReturn) that
is not “attached” to the current form. In VBA I open a recordset based on
tblReturn, add a new record, update the table
set recordset = db.openrecordset(“tblReturn”)
rec.addnew
--- add data to the recordset
rec.update
rec.close

All works, the new record appears in the form.
One field in the table must be entered by the user, so I open a new form
(data source is tblReturn), with focus set on the control bound to the field
that needs to be entered, with WindowMode:=acDialog, so when the new form is
closed, I go back to the first form. The forms OnCurrent event moves to the
last record using the DoCmd.GoToRec acLast. The control that accepts input
has enabled=Yes, locked=No (all other controls on the form have enabled=no,
locked=yes – so the user doesn’t accidently change something). When the form
opens, it shows the last record (entered in VBA), but the problem is that the
control will not accept any data, it looks like the control has enabled =
Yes, and locked = Yes, i.e. cursor is in the control but you cannot change
the default value.
If I delete control source for the control so it is unbound, I can enter data.

The new form (tblReturn) is based on an another existing form used by the
user to enter all data into the table manually, and it works fine. The only
form property I changed was the OnCurrent event to go to the last record.

Does anyone have any ideas?? -- Thanks, Garry Gross

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
O

Ofer

Does the can edit property of the form set to true?
If you run the SQL that the form is bounded to, without the form, can you
update the field? Mybe the problem with the SQL and not with the form
I assume that the form is not locked

If you OK with all of the question above, can you send the line command you
are using to open the form
 
G

Garry

Changed the code to use OnLoad - same result

RuralGuy said:
The OnCurrent event is a poor choice to move the record pointer which creates
another OnCurrent event! I would use the OnLoad event.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
G

Garry

The forms Allow Edits property is set to Yes. Saved the forms SQL to a query
and it runs fine by itself. The code to open the form is:

DoCmd.OpenForm "frmSaleCashRtn_DefectCredit", , WindowMode:=acDialog
 
O

Ofer

Try this
DoCmd.OpenForm "frmSaleCashRtn_DefectCredit", , , , ,acDialog

You put the acDialog in the wrong place
 
O

Ofer

Ignore the prev post, I don't think it will make a different

Does the field bounded to field in the table, or to a formula like a join
between two tables, dlookup, or a calculation, in that case you wont be able
to update the field
 
G

Garry

Thanks for your effort, but I've decided I've spent too much time on this and
since an unbound control on the form seems to work, I will do that and "grab
it" in VBA and save to the table using a recordset.
Again, Thanks for your effort -- Garry
 
Top