To have a selection of year to merge

  • Thread starter Frank Situmorang
  • Start date
F

Frank Situmorang

Hello,

In my Form there is a commandkey to merge to the All records and below is
the VBA, my question is how can we make it like a combo box to chose the
year, because the user is not a programmer, and is not able to open it in
design view and change the VBA.

Private Sub cmdMergeAll_Click()

Me.Refresh
MergeAllWord ("select * from PelayanJemaat Where TahunPel=2008")
'Note that you could use a condtion in the above sql
End Sub

Thanks in advance for any help provided.
 
K

Klatuu

Put a control on your form where the user can enter the date. For example
purposes, I will call it txtMergeYear

Private Sub cmdMergeAll_Click()
Dim lngMergeYear As Long

If IsNull(Me.txtMergerYear) Then
MsgBox "A Year is Required"
Exit Sub
Else
lngMergeYear = Clng(Me.txtMergeYear)
End If
Me.Refresh
MergeAllWord ("select * from PelayanJemaat Where TahunPel= " &
lngMergeYear)
'Note that you could use a condtion in the above sql
End Sub
 
F

Frank Situmorang

Klatuu,

How if txtMergerYear, we use combo in the form, to be user friendly. What is
the VBA.

Thanks in advance for your help
 
K

Klatuu

I'm not convinced a combo is more user friendly in this case, but it wouldn't
need to be any VBA, just make your Row Source Type a Value List and enter a
range of years:

1999;2000;2001;2002;2003;2004;2005;2006;2007;2008;2009;2010
 
F

Frank Situmorang

Klatuu:

I have tried your suggestion but it can not work.
Let me provide you additional formation.

My MergeSingleWord button is in the form when we fill in the name of the
chruch officer, the year of service and it can perfecly work.

In the same form I put a button of MergeAll. and then to do your seggestion
I put a textbox on it for the txtMergerYear like you said.

But when it comes to give the rowsource of this textbox, how can it be,
because the table based of this form will not enable us to put the value list
in the textbox.

I appreciate your help.
 
K

Klatuu

I don't see why it would not work. Your original code:
MergeAllWord ("select * from PelayanJemaat Where TahunPel=2008")

Using a combo box to select the year, it would be:
MergeAllWord ("select * from PelayanJemaat Where TahunPel=" & Me.YearCombo)
 

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