open form, to record selected in other form.

morfusaf

Registered User.
Local time
Today, 13:03
Joined
Apr 24, 2012
Messages
78
I have a form, formCreatenewEvent

on this form I can create new events...

I want to be able to update events as well.

So, I have main home form... on there I have a button to update form... then 2 combo boxes and a text box..

The first combo box you select the date of the event, 2nd combo box you select the title of the event...
and the text box needs to pull the type of event EventType field. from my tblEvent

Then I need to press a button, and have this open my formCreateEvent form up to the event selected on the previous form... Also, i have 4 different types of events, each one has a different createnewevent form... ex. formCreateHGEvent formCreateREEvent..


So, I need help coding the combo boxes and text box and button to pass the info to the correct form and open to that record so I can edit then save it.


I have the method on how to populate the Event titles by date... so now I need how to pass the event type(text box) and have a proper if txtboxEventType = RE Event ... docmd.openform CreateREEvent.

Any help?
 
The combo that selects the actual EventID must include a column with the EventType. Then in the click event of the button that opens the edit form, use a select case to chose which form to open and pass along the eventID in the where argument.
Code:
Dim stLinkCriteria as String
stLinkCriteria = "EventID = " & Me.cboEvent
Select Case Me.cboEvent.Column(2)
    Case 1
        DoCmd.OpenForm "form1name", , , stLinkCriteria
    Case 2
        DoCmd.OpenForm "form2name", , , stLinkCriteria
    Case 3
        DoCmd.OpenForm "form3name", , , stLinkCriteria
    Case 4
        DoCmd.OpenForm "form4name", , , stLinkCriteria
End Select
The .column() property of a combo's RowSource is a zero-based array. So .column(0) refers to the first column in the query, .column(1) is the second, etc.
 
I've never done anything with case.

So i am kind of confused.

I am not understanding how I decide which case is which type of form.


Where do I desginate that Case 1 = HG Event
and case 2 = RE Event ?

I am assuming, that where you put the stLinkCriteria (this is the where condition of that , so I am assuming this is where I put EventType = "HGEvent", or ...?
 
If the values are text, substitute the text value.

Case "HG Event"
..
Case "RE Event"
...

No the EventType determines which form to open. You need a record key (I called it EventID) to tell the form which record to open to. That's what the stLinkCriteria is for.
 
OK, I have been gone, but I am back and working this again...

I can't seem to get it to work.

Here is my code,

Code:
Private Sub btnUpdate_Click()
 
Dim stLinkCriteria As String
stLinkCriteria = "[EventID] = " & Me.cboWhichEvent
Select Case Me.cboWhichEvent.Column(2)
    Case "Funeral - Veteran"
        DoCmd.OpenForm "formCreateNewVetFuneralEvent", , , stLinkCriteria
    Case "Funeral - Retiree"
        DoCmd.OpenForm "formCreateNewRetFuneralEvent", , , stLinkCriteria
    Case "Funeral - Active Duty"
        DoCmd.OpenForm "formCreateNewADFuneralEvent", , , stLinkCriteria
    Case "Color Guard"
        DoCmd.OpenForm "formCreateNewColorGuardEvent", , , stLinkCriteria
End Select
 
End Sub

I tried to change ...
Code:
  "[EventID] = " to...     "EventID = "
Neither worked.

I clicked the button and nothing seemed to happen.

Ok, ...

So I have the following happening.....

I select the date, Then I select the event title... from those on that date... then it populates a field(EventType) with what the event type is from that record...

I want to pass that Event type to the case... and depending on which EventType depends on which form to open...


I changed the EventID to EventType and stilll didn't work.
 
Never Mind... I was able to figure it out...

Used the following

Code:
Dim stLinkCriteria As String
stLinkCriteria = "EventType = " & Me.cboWhichEvent
Select Case Me.EventType
    Case "Funeral - Veteran"
        DoCmd.OpenForm "formCreateNewVetFuneralEvent"
    Case "Funeral - Retiree"
        DoCmd.OpenForm "formCreateNewRetFuneralEvent"
    Case "Funeral - Active Duty"
        DoCmd.OpenForm "formCreateNewADFuneralEvent"
    Case "Color Guard"
        DoCmd.OpenForm "formCreateNewColorGuardEvent"
End Select
 

Users who are viewing this thread

Back
Top Bottom