S
sgyan1
This is my first time to develop database application using ms-access so
please consider me as a beginner
I need to know 2 main things
- how to get value from query and assign the value to a variable in VBA
Code
- how to get autonumber value from system table and assign to a variable
in VBA
There are 2 tables:
ENROL (sid, eid, cid)
CLASS (cid, cname, ctype, lvid, vid, coid, is_on)
I need to execute following transaction in VBA code
Dim intSID as Integer = Forms!frmStudent!sid
Dim intCID as Integer
intCID = SELECT TOP 1 C.cid
FROM ENROL E, CLASS C
WHERE E.cid = C.cid
AND E.sid = intSID
AND C.ctype = 2;
If intCID = NULL Then
intCID = (value from autonumber) /* cid; autonumber */
INSERT INTO CLASS (cid, ctype)
VALUES (intCID, 2);
End If
INSERT INTO ENROL (sid, cid) /* eid; autonumber */
VALUES (intSID, intCID);
* I am thinking about creating scalar function (returns 'cid' or autonumber
value) as a module and execute it in VBA code. Is it possible? if so, how it
can be implemented in VBA code?
Thanks for your time.
Daniel Yang
please consider me as a beginner
I need to know 2 main things
- how to get value from query and assign the value to a variable in VBA
Code
- how to get autonumber value from system table and assign to a variable
in VBA
There are 2 tables:
ENROL (sid, eid, cid)
CLASS (cid, cname, ctype, lvid, vid, coid, is_on)
I need to execute following transaction in VBA code
Dim intSID as Integer = Forms!frmStudent!sid
Dim intCID as Integer
intCID = SELECT TOP 1 C.cid
FROM ENROL E, CLASS C
WHERE E.cid = C.cid
AND E.sid = intSID
AND C.ctype = 2;
If intCID = NULL Then
intCID = (value from autonumber) /* cid; autonumber */
INSERT INTO CLASS (cid, ctype)
VALUES (intCID, 2);
End If
INSERT INTO ENROL (sid, cid) /* eid; autonumber */
VALUES (intSID, intCID);
* I am thinking about creating scalar function (returns 'cid' or autonumber
value) as a module and execute it in VBA code. Is it possible? if so, how it
can be implemented in VBA code?
Thanks for your time.
Daniel Yang