I have an IF statement and a SELECT CASE statement that were coded in 2 different ways as shown. One takes less coding then the other. So far there is no error occurr. Is it always the case, either method is correct.
If Me!fraNoteOpts.Value = 1 Then
sqltext = "Select Distinct id_rssd, [nm_short] From [tbl_A] WHERE [nm_short] Like '" & Chr$(Me![fraButtonFrame]) & "*';"
ElseIf Me!fraNoteOpts.Value = 2 Then
sqltext = "SELECT Distinct RSSD, BkName FROM tblNotes WHERE BkName Like '" & Chr$(Me![fraButtonFrame]) & "*';"
ElseIf Me!fraNoteOpts.Value = 3 Then
sqltext = "SELECT Distinct RSSD, BkName FROM tblNotes WHERE BkName Like '" & Chr$(Me![fraButtonFrame]) & "*';"
ElseIf Me!fraNoteOpts.Value = 4 Then
sqltext = "SELECT Distinct RSSD, BkName FROM tblNotes WHERE BkName Like '" & Chr$(Me![fraButtonFrame]) & "*';"
End If
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If Me!fraNoteOpts.Value = 1 Then
sqltext = "Select Distinct id_rssd, [nm_short] From [tbl_A] WHERE [nm_short] Like '" & Chr$(Me![fraButtonFrame]) & "*';"
ElseIf Me!fraNoteOpts.Value = 2 Or Me!fraNoteOpts.Value = 3 Or Me!fraNoteOpts.Value = 4 Then
sqltext = "SELECT Distinct RSSD, BkName FROM tblNotes WHERE BkName Like '" & Chr$(Me![fraButtonFrame]) & "*';"
End If
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Select Case fraNoteOpts
Case 1
sqltext = "select distinct left(nm_short,1)from [tbl_A];"
fraButtonFrame = Null
Case 2
sqltext = "SELECT distinct left(BkName,1)FROM tblNotes;"
fraButtonFrame = Null
Case 3
sqltext = "SELECT distinct left(BkName,1)FROM tblNotes;"
fraButtonFrame = Null
Case 4
sqltext = "SELECT distinct left(BkName,1)FROM tblNotes;"
fraButtonFrame = Null
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
GoTo ExitProcedure
End Select
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Select Case fraNoteOpts
Case 1
sqltext = "select distinct left(nm_short,1)from [tbl_FINAL_A];"
fraButtonFrame = Null
Case 2, 3, 4
sqltext = "SELECT distinct left(BkName,1)FROM tblNotes;"
fraButtonFrame = Null
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
GoTo ExitProcedure
End Select
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar