Pass data from one form to another

I have used some queries, infact I think I have used way too many in other areas, but in this case I haven't
 
Queries take up very little space in a db as they are just the SQL and some strategy. Let's modify the Load Event code.
 
Code:
Private Sub Form_Load()
Dim strOpenArgs() As String

If Not IsNull(Me.OpenArgs) Then
  strOpenArgs = Split(Me.OpenArgs, ";")
  Me.cboNameOfComboBox = strOpenArgs(0)
'.. If there were more arguments
'  Me.txtAnotherTextBox = strOpenArgs(1)
Else
' .. Do something else
End If
End Sub
 
BTW, does the ComboBox have a ControlSource (Is it Bound)?
 
RuralGuy you are a genius!!!! It worked!!!! Thank you sooo much
I don't know whether it is bound... I don't know what that means :-) I think I have been a bit ambitious with this database lol... it's getting there slowly though!
The next step is to update the comments shown on form one with the newly added comment, but I shall have a go and see.
I have to go home from work now, but that you so much for taking the time out of your day to offer me some friendly advice.
It means a lot and I am very grateful. I'm sure as you have done a good deed today in helping me that your day will be truly wonderful :-)
 
Check back tomorrow. We need to cover a couple of additional things. Go home for now and I'll leave the posts for you to read later.
 
For the record, bound Control means it has a ControlSource, bound Form means it has a RecordSource. Basically when you change the value it is changing the value in a table somewhere. Unbound, that is not the case unless you do the changing yourself.
If the 1st form is displaying the "Comments" that you changed with the 2nd form, there is a way to get them to show up on form #1 automatically. Just post back and we'll do it. BTW, did you decide to change the ComboBox into a TextBox? I think it would be a good idea. Just my $0.02 :)
 
As you gain experience in MS Access you will discover other methods to pass values between forms. I prefer the one I used because it doed not require the form to know anything about who launched it. It is more modular that way. :)
 
I have one other step I would like to know how to code in reference to this topic. This worked great for what I needed with one caveat, it allows duplicate records to be created for the same [Offer_ID] in my table.

How can I get it to look for an existing record using [Offer_ID] and open the record should it exist already or create a new record if it does not?

On Click On Form 1

On Error GoTo Err_cmdOpen_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSLR_ChainInvoice_Detail"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.OFFER_ID

Exit_cmdOpen_Click:
Exit Sub

Err_cmdOpen_Click:
MsgBox Err.Description
Resume Exit_cmdOpen_Click

End Sub

Form Load Event on Form 2

Private Sub Form_Load()
Dim strOpenArgs() As String

If Not IsNull(Me.OpenArgs) Then
strOpenArgs = Split(Me.OpenArgs, ";")
Me.OfferID = strOpenArgs(0)

Else
' .. Do something else
End If

End Sub
 
Hello, I'm getting a Run time error while running the code, says Microsoft Access couldn't print your object.

In my case I've applied it on a report where a button is available for certificate printing. This report returns a list of assets assigned on a particular employee. The OpenArgs on the Do.cmd can already get the ID of the button where it is being clicked. However the stlinkCriteria returns 0, maybe this is causing me the problem, please Help, I'm really stuck. thank you so much in advance.
 
can you post the code you have on opening the report.
you only need to provide the strLinkCriteria:

strLinkCriteria = "[ID] = " & ME!ID
docmd.OpenReport ReportName:="yourReport",WhereCondition:=strLinkCriteria
 

Users who are viewing this thread

Back
Top Bottom