Form does no longer bind to table

  • Thread starter Thread starter Jørn Nystad
  • Start date Start date
J

Jørn Nystad

Hi

I have a strange problem with my Access 2000 db.
Its a multiuser environment with backend and frontend mdb files.
Backend has only tables and frontend have all the forms, queries and code.
I'm only using VBA code and no macros.
Average 6 users using the system at the same time.
I have made noe relations between tables.

Now to the problem.
A form with datasource set directly to a table does not bind to the data in
the table anymore.
The form has only default settings in the data tab of the properties window.
The form is modal.
The form ('cause of many fields in the table) has a lot of controls. Prob
around 30 or so.

I use
DoCmd.Openform "Myform", , , "[SD_PR_ID] = " & CStr(Me!PR_ID)
to open the form.

in MyForm_Open() i have some code to fill a unbound label.
In MyForm_Current() i have som formatting code.

The form does not bind without filter either. Like this:
DoCmd.Openform "Myform"

And thats about it.
After editing a command button in the form i compiled the VBA code and
runned "Compress and repair".
Then the form refused to bind to the table.
The old version is working, but ive done so much editing that i would like
to get the newest version to work.

Anyone experienced this before?
I've tried everything i could think of. Do i really have to build a new
form?

Any help would be appreciated.
 
Jørn Nystad said:
Hi

I have a strange problem with my Access 2000 db.
Its a multiuser environment with backend and frontend mdb files.
Backend has only tables and frontend have all the forms, queries and
code. I'm only using VBA code and no macros.
Average 6 users using the system at the same time.
I have made noe relations between tables.

Now to the problem.
A form with datasource set directly to a table does not bind to the
data in the table anymore.
The form has only default settings in the data tab of the properties
window. The form is modal.
The form ('cause of many fields in the table) has a lot of controls.
Prob around 30 or so.

I use
DoCmd.Openform "Myform", , , "[SD_PR_ID] = " & CStr(Me!PR_ID)
to open the form.

in MyForm_Open() i have some code to fill a unbound label.
In MyForm_Current() i have som formatting code.

The form does not bind without filter either. Like this:
DoCmd.Openform "Myform"

And thats about it.
After editing a command button in the form i compiled the VBA code and
runned "Compress and repair".
Then the form refused to bind to the table.
The old version is working, but ive done so much editing that i would
like to get the newest version to work.

Anyone experienced this before?
I've tried everything i could think of. Do i really have to build a
new form?

Any help would be appreciated.

What exactly makes you think the form is "refusing to bind to table"? Describe
the *behavior* you are seeing rather than what you think is happening.

If the RecordSource property is the name of a table then the form is bound to
that table.
 
The symptoms you describe indicate that the form has become corrupt, but
there are ways to try to rescue it. Try this sequence.

1. Make a backup so you get multiple chances at recovery.

2. If you can open the module of the form, make a copy of the text there. If
you do have to recreate the form from scratch, you would then paste this
text back in, and not have to re-write all code from scratch.

3. Make sure that the Name AutoCorrect boxes are unchecked under:
Tools | Options | General
Explanation:
http://allenbrowne.com/bug-03.html
Then compact the database to get completely rid of this stuff.

4. Close Access and decompile the database. This dumps the compiled version
of the code, and VBA will later create it from the text. To decompile, enter
something like this at the command prompt while Access is not running. It is
all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
Then compact again.
At this point you can test the form to see if it is working yet.

5. If still broken, try to export the form to a text file, using the
undocumented SaveAsText. This kind of thing:
SaveAsText acForm, "Form1", "C:\Form1.txt"
If that fails, the form is generally beyond simple repair. If it succeeds,
create a new (blank) database, turn off Name AutoCorrect, and import all the
*other* objects from your database. Then try loading this form from the text
file:
LoadFromText acForm, "Form1", "C:\Form1.txt"

6. If the form is still broken, create it again from scratch in the new
database created at step 5, and paste in the code you saved at step 2.

For suggestions on how to avoid the database corrupting in future, see:
Preventing Corruption
at:
http://allenbrowne.com/ser-25.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Jxrn Nystad said:
I have a strange problem with my Access 2000 db.
Its a multiuser environment with backend and frontend mdb files.
Backend has only tables and frontend have all the forms, queries and code.
I'm only using VBA code and no macros.
Average 6 users using the system at the same time.
I have made noe relations between tables.

Now to the problem.
A form with datasource set directly to a table does not bind to the data
in the table anymore.
The form has only default settings in the data tab of the properties
window.
The form is modal.
The form ('cause of many fields in the table) has a lot of controls. Prob
around 30 or so.

I use
DoCmd.Openform "Myform", , , "[SD_PR_ID] = " & CStr(Me!PR_ID)
to open the form.

in MyForm_Open() i have some code to fill a unbound label.
In MyForm_Current() i have som formatting code.

The form does not bind without filter either. Like this:
DoCmd.Openform "Myform"

And thats about it.
After editing a command button in the form i compiled the VBA code and
runned "Compress and repair".
Then the form refused to bind to the table.
The old version is working, but ive done so much editing that i would like
to get the newest version to work.

Anyone experienced this before?
I've tried everything i could think of. Do i really have to build a new
form?

Any help would be appreciated.
 
Rick Brandt said:
Jørn Nystad said:
Hi

I have a strange problem with my Access 2000 db.
Its a multiuser environment with backend and frontend mdb files.
Backend has only tables and frontend have all the forms, queries and
code. I'm only using VBA code and no macros.
Average 6 users using the system at the same time.
I have made noe relations between tables.

Now to the problem.
A form with datasource set directly to a table does not bind to the
data in the table anymore.
The form has only default settings in the data tab of the properties
window. The form is modal.
The form ('cause of many fields in the table) has a lot of controls.
Prob around 30 or so.

I use
DoCmd.Openform "Myform", , , "[SD_PR_ID] = " & CStr(Me!PR_ID)
to open the form.

in MyForm_Open() i have some code to fill a unbound label.
In MyForm_Current() i have som formatting code.

The form does not bind without filter either. Like this:
DoCmd.Openform "Myform"

And thats about it.
After editing a command button in the form i compiled the VBA code and
runned "Compress and repair".
Then the form refused to bind to the table.
The old version is working, but ive done so much editing that i would
like to get the newest version to work.

Anyone experienced this before?
I've tried everything i could think of. Do i really have to build a
new form?

Any help would be appreciated.

What exactly makes you think the form is "refusing to bind to table"?
Describe the *behavior* you are seeing rather than what you think is
happening.

If the RecordSource property is the name of a table then the form is bound
to that table.

Hi Rick

Ive tried the following steps with the form bound to a table, linked table
and a query, through the RecordSource property, and the result is the same.


Well, i step through the code and the
DoCmd.Openform "Myform", , , "[SD_PR_ID] = " & CStr(Me!PR_ID)
presents the correct PR_ID in me!PR_ID

then, of course, the form opens and run
MyForm_Open()
which only fill a unbound label with som settings
and then
MyForm_Current()
runs to formatt some of the controls (enabled, not enabled and so on)
then the form is displayed to the user.

But there's no recordset in the form although a query proves the records
exists.
There's a listbox control in the form, for fast finding records, and this
listbox displayes the right records.
But when i click the list box i does not jump to any records because
me.recordset.clone returns no records.

If i set the AllowAdditions = false and open the form the form displayes no
controls.

Was this helpful?
Sorry for my english, its only a second language to me.

regards
Jørn Nystad
 
Jørn Nystad wrote:
[snip]
If i set the AllowAdditions = false and open the form the form
displayes no controls.

And the above happens even when you bind the form directly to a table that
contains record? It sounds like your form is bound to a query or SQL statement
that returns zero rows which is quite different than saying your form is
refusing to bind.
 
Back
Top