プログラミングに慣れていますが、周りを見渡しましたが、私がここで見た回答をどのように関連付けるのかはわかりません私は何が必要です。私は、私は自分のAccessデータベースで必要がある入力を決定するIF関数をやっています。私はユーザーが私のサブルーチンで入力したものからInpvalをAccessのテーブルに持っていきたいと思っています。VBAのユーザーがAccessデータベースに入力した情報を入力する方法
私のIF機能は次のとおりです。基本的に私が望むのは、以下の値のいずれかが「True」である場合は、その値をAccessテーブルのフィールドに入れて、すべての有効なオプションのレコードを保持できるようにします。
Do Until Keepgoing = False
Message = InputBox("Please enter the module code you would like to enrol in for Semester 1." & vbCrLf & "A list of all available options for " & Inpval & " can be found on the form." & vbCrLf & "(Enter a blank value to exit)")
If Message = "" Then
Keepgoing = False
MsgBox "Blank input entered, terminating program."
Exit Sub
End If
If Message = "SBC120" Then
Count1 = Count1 + 20
BP = BP + 1
BP1 = "Business Programming 1"
ElseIf Message = "SBC110" Then
Count1 = Count1 + 20
IB = IB + 1
IB1 = "International Business 1"
ElseIf Message = "SBC130" Then
Select Case Inpval
Case "HRM"
MsgBox "Sorry, you cannot select Management Science (SBC130) while on the " & Inpval & " programme." & vbCrLf & "See the list of modules available to your programme." & vbCrLf & "Once you are ready to continue, click the 'Return to Form' button and restart the process.", 16, "Module Criteria Not Satisfied"
DoCmd.OpenReport "HRMModsSem1Rpt", acViewReport
Exit Sub
End Select
Count1 = Count1 + 20
Response1 = Response1 + 1
MS1 = "Management Sciences 1"
ElseIf Message = "SBC010" Then
Count1 = Count1 + 10
PreReq1 = InputBox("Warning, you have selected Change Management (SBC010) as one of your modules." & vbCrLf & "This can only be selected if you studied Business Transformation (SBB020) in Year 2." & vbCrLf & "If you have not done so, please type 'No'.", "Change Management Prerequisite")
Select Case PreReq1
Case "No", "NO", "no", "nO", "N", "n"
MsgBox "Sorry, because you have not studied Business Transformation (SBB020)," & vbCrLf & "You do not satisfy the selection critera. Please try again.", 16, "Prerequisite Module Not Selected."
Exit Sub
End Select
CM1 = "Change Management"
ElseIf Message = "SBC020" Then
Count1 = Count1 + 10
Response3 = Response3 + 1
BPlan1 = "Business Planning"
ElseIf Message = "SBC030" Then
Count1 = Count1 + 10
SBI1 = "Small Business Issues"
ElseIf Message = "SBC040" Then
Select Case Inpval
Case "HRM"
MsgBox "Sorry, you cannot select Decision Analysis (SBC040) while on the " & Inpval & " programme." & vbCrLf & "See the list of modules available to your programme." & vbCrLf & "Once you are ready to continue, click the 'Return to Form' button and restart the process.", 16, "Module Criteria Not Satisfied"
DoCmd.OpenReport "HRMModsSem1Rpt", acViewReport
Exit Sub
Case "AM"
MsgBox "Sorry, you cannot select Decision Analysis (SBC040) while on the " & Inpval & " programme." & vbCrLf & "See the list of modules available to your programme." & vbCrLf & "Once you are ready to continue, click the 'Return to Form' button and restart the process.", 16, "Module Criteria Not Satisfied"
DoCmd.OpenReport "AMModsSem1Rpt", acViewReport
Exit Sub
End Select
Count1 = Count1 + 10
Response1 = Response1 + 1
DA1 = "Decision Analysis"
ElseIf Message = "SBC150" Then
MgmtDiss = InputBox("You have selected Management Dissertation (SBC150) as one of your modules." & vbCrLf & "Please specify the number of credits this module will provide for this semester (10 or 20).", "Management Dissertation Module")
Select Case MgmtDiss
Case "10", "Ten", "ten", "TEN"
Count1 = Count1 + 10
MDCred = 10
MsgBox "Thank you, it is required that you select Management Dissertation (SBC150) in your Semester 2 options." & vbCrLf & "This will make up " & 30 - MDCred & " of your Semester 2 credits."
Case "20", "Twenty", "twenty", "TWENTY"
Count1 = Count1 + 20
MDCred = 20
MsgBox "Thank you, it is required that you select Management Dissertation (SBC150) in your Semester 2 options." & vbCrLf & "This will make up " & 30 - MDCred & " of your Semester 2 credits."
Case Else
MsgBox "Incorrect value, please enter '10' or '20'.", 32
End Select
MD = ("Management Dissertation" & MDCred & (30 - MDCred))
Else: MsgBox "Input not recognised, please enter a correct Module Code.", 32
End If
入力ボックスを使用しないでください、フォームを使用します。 – Fionnuala
@Steve Wで提案されている学習に加えて、コンボボックスに利用可能なオプションをリストしたいと思うでしょう。 。 次に、ユーザーの選択に基づいて値を参照することができ、無効な選択についてまったく心配する必要はありません。これにより、コードをもっと小さくすることができます。 – Minty