Button opens a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

To help a user make corrections to the previously entered data, I’ve given
them a form to enter the transaction key and click an OK button. This takes
the user to another form which displays the data they wish to correct.

The problem is that the user has to click the OK button twice to get the
data to display. The first time they click OK, the second form opens up and
the second time they click OK, the data appears. I used the button wizard to
build the code that opens the form. The code is as follows:

Private Sub butOpenfrmLeaveCorrection_Click()
On Error GoTo Err_butOpenfrmLeaveCorrection_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEmpLeaveCorrection"

stLinkCriteria = "[LeaveID]=" & Me![boxLID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_butOpenfrmLeaveCorrection_Click:
Exit Sub

Err_butOpenfrmLeaveCorrection_Click:
MsgBox Err.Description
Resume Exit_butOpenfrmLeaveCorrection_Click

End Sub

What is the way to get the second form’s data to display the first time the
user clicks the OK button.

tia,
 
This is a guess, because I obviously can't see what else is happening in the
application. But is sounds like the value in boxLID isn't saved the first
time the button is pushed, causing the criteria to be incorrect. You might
try saving the record:
DoCmd.RunCommand acCmdSaveRecord
or
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
before setting the criteria.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
I put this DoCmd in several places (On Exit, On Lost Focus, On Change) on the
first form and it's still not working like it should.

Any other suggestions?

tiaa,
JMorrell




Roger Carlson said:
This is a guess, because I obviously can't see what else is happening in the
application. But is sounds like the value in boxLID isn't saved the first
time the button is pushed, causing the criteria to be incorrect. You might
try saving the record:
DoCmd.RunCommand acCmdSaveRecord
or
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
before setting the criteria.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

JMorrell said:
To help a user make corrections to the previously entered data, I've given
them a form to enter the transaction key and click an OK button. This takes
the user to another form which displays the data they wish to correct.

The problem is that the user has to click the OK button twice to get the
data to display. The first time they click OK, the second form opens up and
the second time they click OK, the data appears. I used the button wizard to
build the code that opens the form. The code is as follows:

Private Sub butOpenfrmLeaveCorrection_Click()
On Error GoTo Err_butOpenfrmLeaveCorrection_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEmpLeaveCorrection"

stLinkCriteria = "[LeaveID]=" & Me![boxLID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_butOpenfrmLeaveCorrection_Click:
Exit Sub

Err_butOpenfrmLeaveCorrection_Click:
MsgBox Err.Description
Resume Exit_butOpenfrmLeaveCorrection_Click

End Sub

What is the way to get the second form's data to display the first time the
user clicks the OK button.

tia,
 

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

Back
Top