MS Access 2003 - Save button enabling on form open on different tabs

Posted by Justin on Stack Overflow See other posts from Stack Overflow or by Justin
Published on 2010-03-25T22:45:04Z Indexed on 2010/05/10 13:14 UTC
Read the original article Hit count: 343

I have a tab control on a form, and a couple different tabs have save buttons on them. Once the user saves data (via SQL statements in VBA), I set the .enabled = false so that they cannot use this button again until moving to a brand new record (which is a button click on the overall form).

so when my form open i was going to reference a sub that enabled all these save buttons because the open event would mean new record. though i get an error that says it either does not exist, or is closed.

any ideas?

thanks

EDIT:

Sub Example()
error handling

Dim db as dao.database
dim rs as dao.recordset
dim sql as string

SQL = "INSERT INTO tblMain (Name, Address, CITY) VALUES ("

if not isnull (me.name) then
    sql = sql & """" & me.name & ""","
else
    sql = sql & " NULL,"
end if

if not insull(me.adress) then
    sql = sql & " """ & me.address & ""","
else
    sql = sql & " NULL,"
end if

if not isnull(me.city) then
   sql = sql & " """ & me.city & ""","
else
   sql = sql & " NULL,"
end if

'debug.print(sql)
set db = currentdb
db.execute (sql)

MsgBox "Changes were successfully saved"

me.MyTabCtl.Pages.Item("SecondPage").setfocus
me.cmdSaveInfo.enabled = false

and then on then the cmdSave needs to get re enabled on a new record (which by the way, this form is unbound), so it all happens when the form is re-opened. I tried this:

Sub Form_Open()

me.cmdSaveInfo.enabled = true

End Sub

and this is where I get the error stated above. So this is also not the tab that has focus when the form opens. Is that why I get this error? I cannot enable or disable a control when the tab is not showing?

© Stack Overflow or respective owner

Related posts about forms

Related posts about ms-access