Selection on MergeAll

  • Thread starter Frank Situmorang
  • Start date
F

Frank Situmorang

Hello,

This is my VBA to merge to all " chruch officers " for the year 2008.

Our database could be exists of many years. How can we use the benefit of
merge all but for selected year:

Thi is my 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
 
A

Albert D. Kallal

The first thing we'll need to know is the name of some date field, or how
you actually know that a member is for this year and active?
 
F

Frank Situmorang

Yes Albert, this command mergeall is on the form to fill in the church
officer and there is the field for year, but not the date. this is the number.

May be that is the problem why my VBA does not work??: This is my modified
VBA after informed by someone in this forum:
Private Sub cmdMergeAll_Click()
Dim lngMergeYear As Long

If IsNull(Me.txtMergerYear) Then
MsgBox "Perlu disi tahun"
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
I appreciate your help
 
A

Albert D. Kallal

MergeAllWord ("select * from PelayanJemaat Where TahunPel= " &
lngMergeYear")

The above has a extra "quote" at the end....does the above even compile??

Remote the last trailing quote you have right after LngMergeYear" <--
remote quote.

eg:

MergeAllWord "select * from PelayanJemaat Where TahunPel= " &
lngMergeYear"


Note that if TahunPel a text type field, then you need the following with
quotes (check in the table design mode if TahanPel is number or text).

If it is a text field, then you need to surround the sql with quotes...

eg:

MergeAllWord "select * from PelayanJemaat
Where TahunPel= '" & lngMergeYear & "'"


Watch for word wrapping in the above...they should be on one line....
 
F

Frank Situmorang

I have checked it Albert, the field is a number type, not a text.

So what should I do , There should be no double quote?
 
F

Frank Situmorang

Thanks very much Albert it works perfectly now. Your help is greatful.
 

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