Cant edit Access 2003 form

S

StuJol

i have a form linked to a tbl. when form is opened from the database window,
it defaults to the first record and can be edited. when the form is opened
from a command button on another form, the form cant be edited. no errors
just a sound from my pc.

i've created 2 codes to open this form. both codes wont allow me to edit
current record

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_PlantLog_Add"

stLinkCriteria = "[Record_ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
Msgbox Err.Description
Resume Exit_Command43_Click

End Sub
++++++++++++++++++++++++++++++++
Function ViewCurrentLog() As Boolean

'Open Form
DoCmd.OpenForm "frm_PlantLog_Add", , , , , acHidden

'Select Form
Forms!frm_PlantLog_Add.SetFocus

'Select Last Record
DoCmd.GoToRecord , , acLast

'Display Form
DoCmd.OpenForm "frm_PlantLog_Add", acNormal, , , acFormEdit,
acWindowNormal


End Function

any help would be appreciated.
 
A

Arvin Meyer [MVP]

You cannot set focus to a hidden form. Your code is most likely stopping.
 
S

StuJol

i dont beleive the code is stopping as the form opens. even using the Private
Sub Command43_Click() code which doesnt hide the form, im still unable to
edit. it has previously worked using the set focus command on a hidden form.


Arvin Meyer said:
You cannot set focus to a hidden form. Your code is most likely stopping.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


StuJol said:
i have a form linked to a tbl. when form is opened from the database
window,
it defaults to the first record and can be edited. when the form is opened
from a command button on another form, the form cant be edited. no errors
just a sound from my pc.

i've created 2 codes to open this form. both codes wont allow me to edit
current record

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_PlantLog_Add"

stLinkCriteria = "[Record_ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
Msgbox Err.Description
Resume Exit_Command43_Click

End Sub
++++++++++++++++++++++++++++++++
Function ViewCurrentLog() As Boolean

'Open Form
DoCmd.OpenForm "frm_PlantLog_Add", , , , , acHidden

'Select Form
Forms!frm_PlantLog_Add.SetFocus

'Select Last Record
DoCmd.GoToRecord , , acLast

'Display Form
DoCmd.OpenForm "frm_PlantLog_Add", acNormal, , , acFormEdit,
acWindowNormal


End Function

any help would be appreciated.
 
S

StuJol

after copying the database and deleting bit by bit have came across the
reason for not being able to edit my record from my form.

a subform was also looking at the same table which was open at the same
time. the subforms Record Locks was set to All Records, which prevented me
from being able to edit from the other form.

Its now set to no locks and all works fine now.

thanks for you help.



StuJol said:
i dont beleive the code is stopping as the form opens. even using the Private
Sub Command43_Click() code which doesnt hide the form, im still unable to
edit. it has previously worked using the set focus command on a hidden form.


Arvin Meyer said:
You cannot set focus to a hidden form. Your code is most likely stopping.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


StuJol said:
i have a form linked to a tbl. when form is opened from the database
window,
it defaults to the first record and can be edited. when the form is opened
from a command button on another form, the form cant be edited. no errors
just a sound from my pc.

i've created 2 codes to open this form. both codes wont allow me to edit
current record

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_PlantLog_Add"

stLinkCriteria = "[Record_ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
Msgbox Err.Description
Resume Exit_Command43_Click

End Sub
++++++++++++++++++++++++++++++++
Function ViewCurrentLog() As Boolean

'Open Form
DoCmd.OpenForm "frm_PlantLog_Add", , , , , acHidden

'Select Form
Forms!frm_PlantLog_Add.SetFocus

'Select Last Record
DoCmd.GoToRecord , , acLast

'Display Form
DoCmd.OpenForm "frm_PlantLog_Add", acNormal, , , acFormEdit,
acWindowNormal


End Function

any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top