Q&A to VBA Program Conversion

Programming Statement Differences

Q&A program Visual Basic
#1111: v11111Field1:
if <condition>, <then>, <else> Iif(<condition>, <then>, <else>
if <condition>, <then>, <else> If <condition> then
    <then action>
Else if
    <else action>
Endif
lookup(<input>,<column>, <destination>)
assumes the Q&A Lookup table
<destination> = dlookup(<return>,<table>,"<condition>")
   

Q&A #1111: if #2222 <> "" then lookup(#3333,2, #4444)

Access Query

v1111Field1: iif([v2222Field2] <> "" ,lookup([v3333Field3],2, [v4444Field4]))
VBA If Forms!fMyForm![v2222Field2] <> "" then
   Forms!fMyForm![v4444Field4] = dlookup("nColumn","LOOKUP","Key=Forms!fMyForm![v3333Field3]")
End If

Q&A #1111: if #2222 ="N" then begin #3333 ="3"; #4444 ="4"; #5555 ="5"; end

Access Query

v1111Field1: iif([v2222Field2] ="N" ,begin [v3333Field3] ="3", [v4444Field4] ="4", [v55555Field5] ="5", end)
VBA If Forms!fMyForm![v2222Field2] ="N" then
   Forms!fMyForm![v3333Field3] ="3"
   Forms!fMyForm![v4444Field4] ="4"
   Forms!fMyForm![v5555Field5] ="5"
End If

Q&A #1111: if #2222 <>"" then lookup(#3333, 2, #4444)

Access Query

v4444Field4: iif(v2222Field2] <>"" ,lookup([v3333Field3], 2)
VBA If Forms!fMyForm![v2222Field2] <>"" then
   Forms!fMyForm![v4444Field4] = dlookup("N2","LOOKUP","Key=Forms!fMyForm![v3333Field3]")
End If

For example

Q&A

#1100: if #0956 <>"" then lookup(#0218,2, #0941)

Access Query

v1100F209f2: iif([v0956HColon] <>"" ,lookup([v0218KG1],2, [v0941HH]))
VBA If Forms!fMAX123![v0956HColon] <>"" then
   Forms!fMAX123![v0941HH] = dlookup("N2","LOOKUP","Key=Forms!fMAX123![v0218KG1]")
End If

Q&A Conversion