Import Problem on Form (1 Viewer)

Haynesey

Registered User.
Local time
Today, 20:04
Joined
Dec 19, 2001
Messages
190
Hi,

I have a button on a form that imports data into a table. This works fine. However, after the import, once data exists in the form, I need the button to be disabled so no new import can take place.

This database needs to be finished today so am starting to panic a bit now!!

Can anybody offer any advice?

Thanks in advance

Lee:mad:
 

Dave31

Registered User.
Local time
Today, 20:04
Joined
Oct 11, 2006
Messages
68
Code:
Set db = CurrentDb
    
Set r = db.openrecordset("Table")

r.MoveFirst
Do Until r.EOF
     If isnull("anyfield")Then
     importbutton.enabled = true
     Exit Do
     else
importbutton.enabled = false
        Exit Do
   
 End If
 Loop

something like that, it will check the table, and if there is a record in there, then it will disable the button
 

Haynesey

Registered User.
Local time
Today, 20:04
Joined
Dec 19, 2001
Messages
190
Thanks

Hi Dave,

Thanks for that, am not that experienced on things like this, can you advise me on the following please?

Where do I paste all this code? Also, does it all go in the same area?

Thanks

Lee
 

Dave31

Registered User.
Local time
Today, 20:04
Joined
Oct 11, 2006
Messages
68
you can put that code in the Onload event so everytime you open up the form, it will check that the data is present or not and disable/enable the button as approprate.
Although, as soon as you press the import button (if the import is enabled), the button should disable aswell. so add this to the onclick event of the button:
Code:
importcommand.enabled = false

hope this helps
 

Haynesey

Registered User.
Local time
Today, 20:04
Joined
Dec 19, 2001
Messages
190
Thanks

Thanks, that worked great!

Cheers

Lee
 

Haynesey

Registered User.
Local time
Today, 20:04
Joined
Dec 19, 2001
Messages
190
Problem found!!

Hi,

This works fine but I have now encountered another problem that is related to this code.

This worked perfectly when there was only one button that needed to be disabled when one table had data in it.

However, now there is another 2 buttons that relate to another two tables.

The question is really, how can I change this code so that depending on which tables have data in them.

Any ideas?

Thanks in advance.

Lee
 

Users who are viewing this thread

Top Bottom