473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to pass the record between forms?

I have a data entry form called Draw. This form is used to enter data
in the table called Draw. The table has the following fields:
WholesalerID, MagID, IssueID, CopiesDist, and the index is called
DrawIndex. The DrawIndex is a combination autonumber index that uses
the
combination of these three fields WholesalerID, MagID, IssueID to
ensure that each record is unique.

When a used tries to enter data that has a the same WholesalerID,
MagID, IssueID combination as an existing record, I set it up so that
that error triggers a yes/no box. I'd like the user to have the
option to edit the existing record in the table. I want another form
called EditDrawForm to open so they can modify the existing record if
they choose to do so.

How do I pass the existing record to the new form?

Here's my script so far. Any help would be greatly appreciated.
Someone suggested OpenArgs, but I'm not sure how to use that here...

Option Compare Database

Private Sub ButtonAddDraw_Click()
On Error GoTo Err_ButtonAddDraw_Click
DoCmd.GoToRecord , , acNewRec

Exit_ButtonAddDraw_Click:
Exit Sub

Err_ButtonAddDraw_Click:
Select Case Err.Number
Case 2105
Err.Clear
'* Display my custom message box
If MsgBox("The draw has already been entered for this issue.
Would you like to edit it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "MyForm"
Else
End If
GoTo Exit_ButtonAddDraw_Click
Case Else
MsgBox Err.Description
End Select
Resume Exit_ButtonAddDraw_Click

End Sub

I guess one of my questions is that when the user inputs the info in
the first form and the form checks the table and finds that a record
already exists and triggers the error does that make that record have
the focus?

That's where I'm kind of stuck. I don't know if it's best to open an
editing ofrm with the existing record using openform and openargs (and
I'm not sure how to do this even after having read the help on
openargs) or is it best to use a query to pop up the editing form.

The thing I'm having trouble with is how to pass the record between
the forms.

Don
Nov 12 '05 #1
3 5160
Look at the WhereCondition argument of DoCmd.OpenForm.

But also consider the option of using the Form you have displayed by
locating to the existing record (how you'd do this will depend on the Form's
RecordSource... it may be as simple as finding the record in the
Recordsetclone, which I suspect you have already done, and resetting the
Form's Bookmark property from the Recordsetclone's Bookmark property, then
changing the AllowEdits property.

Larry Linson
Microsoft Access MVP

"Don Seckler" <dj*******@hotmail.com> wrote in message
news:fe**************************@posting.google.c om...
I have a data entry form called Draw. This form is used to enter data
in the table called Draw. The table has the following fields:
WholesalerID, MagID, IssueID, CopiesDist, and the index is called
DrawIndex. The DrawIndex is a combination autonumber index that uses
the
combination of these three fields WholesalerID, MagID, IssueID to
ensure that each record is unique.

When a used tries to enter data that has a the same WholesalerID,
MagID, IssueID combination as an existing record, I set it up so that
that error triggers a yes/no box. I'd like the user to have the
option to edit the existing record in the table. I want another form
called EditDrawForm to open so they can modify the existing record if
they choose to do so.

How do I pass the existing record to the new form?

Here's my script so far. Any help would be greatly appreciated.
Someone suggested OpenArgs, but I'm not sure how to use that here...

Option Compare Database

Private Sub ButtonAddDraw_Click()
On Error GoTo Err_ButtonAddDraw_Click
DoCmd.GoToRecord , , acNewRec

Exit_ButtonAddDraw_Click:
Exit Sub

Err_ButtonAddDraw_Click:
Select Case Err.Number
Case 2105
Err.Clear
'* Display my custom message box
If MsgBox("The draw has already been entered for this issue.
Would you like to edit it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "MyForm"
Else
End If
GoTo Exit_ButtonAddDraw_Click
Case Else
MsgBox Err.Description
End Select
Resume Exit_ButtonAddDraw_Click

End Sub

I guess one of my questions is that when the user inputs the info in
the first form and the form checks the table and finds that a record
already exists and triggers the error does that make that record have
the focus?

That's where I'm kind of stuck. I don't know if it's best to open an
editing ofrm with the existing record using openform and openargs (and
I'm not sure how to do this even after having read the help on
openargs) or is it best to use a query to pop up the editing form.

The thing I'm having trouble with is how to pass the record between
the forms.

Don

Nov 12 '05 #2
> How do I pass the existing record to the new form?

One of the parameters of the DoCmd.OpenForm command is a filter. You
just pass a valid WHERE clause to it. The wizard pretty much builds
everything for you...

Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Staff"

stLinkCriteria = "[StaffName]=" & "'" & Me![FirstName] & "'"

'----Following is the line you want...
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenForm_Click:
Exit Sub

Err_cmdOpenForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenForm_Click

End Sub
Nov 12 '05 #3

"Don Seckler" <dj*******@hotmail.com> wrote in message
news:fe**************************@posting.google.c om...
I have a data entry form called Draw. This form is used to enter data
in the table called Draw. The table has the following fields:
WholesalerID, MagID, IssueID, CopiesDist, and the index is called
DrawIndex. The DrawIndex is a combination autonumber index that uses
the
combination of these three fields WholesalerID, MagID, IssueID to
ensure that each record is unique.

When a used tries to enter data that has a the same WholesalerID,
MagID, IssueID combination as an existing record, I set it up so that
that error triggers a yes/no box. I'd like the user to have the
option to edit the existing record in the table. I want another form
called EditDrawForm to open so they can modify the existing record if
they choose to do so.

How do I pass the existing record to the new form?

Here's my script so far. Any help would be greatly appreciated.
Someone suggested OpenArgs, but I'm not sure how to use that here...

Option Compare Database

Private Sub ButtonAddDraw_Click()
On Error GoTo Err_ButtonAddDraw_Click
DoCmd.GoToRecord , , acNewRec

Exit_ButtonAddDraw_Click:
Exit Sub

Err_ButtonAddDraw_Click:
Select Case Err.Number
Case 2105
Err.Clear
'* Display my custom message box
If MsgBox("The draw has already been entered for this issue.
Would you like to edit it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "MyForm"
Else
End If
GoTo Exit_ButtonAddDraw_Click
Case Else
MsgBox Err.Description
End Select
Resume Exit_ButtonAddDraw_Click

End Sub

I guess one of my questions is that when the user inputs the info in
the first form and the form checks the table and finds that a record
already exists and triggers the error does that make that record have
the focus?

That's where I'm kind of stuck. I don't know if it's best to open an
editing ofrm with the existing record using openform and openargs (and
I'm not sure how to do this even after having read the help on
openargs) or is it best to use a query to pop up the editing form.

The thing I'm having trouble with is how to pass the record between
the forms.

Don


Best place to get answers is at the official MVP site:
http://mvp.org
Carlo Patel (MVP)
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Deano | last post by:
Thanks for the replies to my previous post. So while I'm on a roll here's another plea for help. I simply need the code for a button on the main form that will create a new record in the...
1
by: Nawab | last post by:
I need to lock a record after a user clicks on a button on my form. Does anyone have any idea how to do this. I tried to create a command button on my form which uses a vb procedure but cannot...
1
by: Jordan Marton | last post by:
Two questions here. 1) Is it possible to make a vertically setup datagrid. Basically, i am populating the grid with only information from one record, and I want it to list downwards as opposed...
2
by: Jenny | last post by:
Hi all How can the following problem be solved: My application uses forms authentication. Normally a start.aspx page should be send to the client before login.aspx is shown. Start.aspx...
3
by: Hei | last post by:
hi, how to pass data cross form? my situation: webFormA for input data, after submit, show webFormB to display report use crystalreport. i just need pass record id for set...
7
by: Justin | last post by:
I am trying to password protect a subdirectory using forms authentication. I am using the "Location" tag to specify the directory to be protected. The login.aspx page is in the root directory of...
0
by: mafandon | last post by:
I am running a report based on parameters from a form. The parameters are between two dates (ie: 1/1/2006 to 1/31/2006). However, I can choose different dates, obviously. My report gets all...
6
by: John | last post by:
Hi I need to block user from moving away from a record using any of First/Last/Prev/Next/New Record or any other way IF the record has not been saved, and displaying a message to the effect...
1
by: river | last post by:
I need to be able to pass the record count of my recordset to another function. The function will perform a task only if the current record is (.AbsolutePosition + 1) = rs1.RecordCount. Is there a...
1
by: chintan85 | last post by:
Hi guys, I want to pass multiple forms to different scripts. Lets say. Can u please help me.. <form action="pass1.py" method="post" name="Submit"> <input name="gene" type="checkbox"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.