View Full Version : Insert Data... Urgent Please


Haytham
03-26-2002, 12:33 PM
Hi All...
I created my db and put the Data Backend in the server, and my Frontend in user's PC.
The problem is that :
Some of my forms are Bound, so only one user can enter, modify ... the data.
Some advices is to create Bound Form and then Push (Insert) data by CmdButton into my table, to avoid this conflict.
I can create Bound Form with specific Fields accordingly.
My problem is how to insert data into my data to the table.
I've never used it before, so expecting a help from you programers with many thanks...

Haytham
03-27-2002, 04:12 AM
Hope to get a help from anyone

Jimbob
03-27-2002, 06:41 AM
Ok, I think you are talking about UNBOUND forms....

Take the form that is now bound, remove it's datasource, and for each field remove the control source.

Say you want to squirt the contents of controls txtName and txtDateAdded to a new record in a table called tblStaff, to fields called Name and DateAdded.

this is how:

Private Sub ctlSubmit_Click
Dim rst as Recordset
Dim db as DataBase
set db = CurrentDb

set rst = Db.OpenRecordset("tblStaff", Db.OPenDynaset)

With rst

.Addnew
!Name = Me!Name
!DateAdded = Me!DateAdded
.Update
.close

end with

End Sub

Pat Hartman
03-27-2002, 09:27 AM
The fact that the forms are bound is NOT causing the problem. Making them unbound will NOT fix this problem.

Make sure that each user opens the database in shared mode. Make sure that each user has sufficient rights for the directory on the server where the backend resides so that Access can create and delete the .ldb file. Make sure that you haven't changed the default record locking method for the queries/tables/forms.

Haytham
03-27-2002, 07:04 PM
Hi Jimbob, thank you for reply.
Well, I tried to put the code as mentioned with changed according to my field name, but
set rst = Db.OpenRecordset("TableName", Db.OPenDynaset) gives me error in OpenDynaset
I don't how to declare the variable...
Expecting more help from you.

Hi Pat, Thank you..
Ok. Every user have a copy of Application db front end linked to the Data backend in the server successfully.
They all have the right to open, delete, modify according to theil level.
When any user open his copy, .ldb is created which can't be deleted. But it disappear (Deleted) when they shut down their copy in the right direction.
The db is opened in a shared mode with No Locks.
Still this problem arise.

Fizzio
03-28-2002, 12:11 AM
Should be

set rst = Db.OpenRecordset("TableName", DbOpenDynaset)

Jimbob
03-28-2002, 02:23 AM
Thanx Fizzio...

Has that fixed it Haytham?

Haytham
03-28-2002, 03:24 AM
No.. I'm getting Run Time Error 13
Type Mismatch.

Jimbob
03-28-2002, 04:45 AM
Do you have accecc '97? if so, go to the debug window, tool, references...check your references are like so:

Visual Basic for Applications (Ticked and at the top of the list)

Microsoft 8.0 Object Library (ticked and second on the list)

Microsoft DAO 3.51 Object Library]

Has that sorted it? or do you have Acess 2000?

Haytham
03-28-2002, 11:23 AM
I'm using Access 2000.

edtab
03-31-2002, 05:29 AM
If you are using Access 2000, you should include as one of your references "Microsoft DAO 3.6 Object Library".

Haytham
03-31-2002, 08:03 PM
Sorry, DAO 3.6 Object Library is already ticked.
Anyway I'll try to fix it.
Thank you