0
votes

on click(), I am having problem or wording in the following:

Private Sub Cmd_Create_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs_conterparty As DAO.Recordset
Dim rsCount As Integer
Dim PE_nb As Integer
Dim BizNO As Field
Dim YearMonth As Field
Dim i, j, k, l, m, n As Integer

Set db = CurrentDb()
Set rs = db.OpenRecordset("TRD_ListofBiz")
Set BizNO = rs.Fields("BizNO")
Set YearMonth = rs.Fields("Year/Month of Delivery")

rs.MoveLast
rsCount = rs.RecordCount

Department = Me!Label_deal_status.Value
PE_nb = [Forms]![MAIN_PHYSICAL]![TRD_CONTERPARTY_PRI_VIEW]![TRD_Pricing-In]!Count

MsgBox (DCount("Year/Month of Delivery", "TRD_ListofBiz", "[Year/Month of Delivery]= '" & Me.Txt_entry & "'"))

I cannot understand why the DCount function does not work, although the a Msgbox well retrieve the "me.Txt_entry"

Thanks for your help.

1
What does it do instead of working? - phoog
A message box appears advising "Run-time error '3075': Syntax error (missing operator) in query expression 'Count(Year/ Month of Delivery)'." - CHARUEL Damien
Enclose it in square brackets ([]) - phoog
Works perfectly thanks. Now I would like to add an second Criteria which is a string but it does not work: MsgBox (DCount("[Year/Month of Delivery]", "TRD_ListofBiz", "[Year/Month of Delivery]= '" & Me.Txt_entry & "' AND [SH_underlying]='TRADING'") - CHARUEL Damien
Sorry I am dumb and missing the last bracket... - CHARUEL Damien

1 Answers

1
votes

Try this:

MsgBox (DCount("[Year/Month of Delivery]", "TRD_ListofBiz", "[Year/Month of Delivery]= '" & Me.Txt_entry & "'"))