We help IT Professionals succeed at work.
Get Started

Insert Into

pdvsa
pdvsa asked
on
310 Views
Last Modified: 2012-05-11
Experts:
In the below, how can I set the value of the combo box on tblLCAmendHistory to ID=14 which corresponds to the word "ISSUE"?
I have a row source qry on AmendType in tblAmendHistory:
SELECT tblLCAmendTypeDropBox.ID, tblLCAmendTypeDropBox.Type FROM tblLCAmendTypeDropBox ORDER BY tblLCAmendTypeDropBox.Type;

I have not tested the below yet so there could be something wrong with the AmendType part.  I dont know if I need it in the first part or if I could remove it completely.

Also, if the LCNo is "" then I would want the code to stop and I think Cancel = True stops the code and therefor no insert.  Let me know that is correct.  

basically what I am doing is after user inputs a date in the field [DateOfIssueSB] then it should INISERT. I am not sure if I should use BeforeUpdate or AFterUpdate.  I think it might be beforeUpdate because need to test if Null but not sure if the date entered by user will be "seen" in the BeforeUPdate event.  

Anyways, any questions please let me know.

Private Sub txtDateOfIssueSB_BeforeUpdate(Cancel As Integer)

       Dim strSQL As String
 
   If Me.LCNo = "" Then
        MsgBox "Enter in the LC No before Entering the Issue Date (need it for Insert Event)"
        Cancel = True
   
     ElseIf (Me.DateOfIssueSB) = "" Then
    'wanting to insert the Date that was entered but only if it was Null before the date was entered.  If not null before update then that means there was a date already entered and dont want to do any Insert.

  strSQL = "INSERT INTO tblLCAmendHistory (AmendedDate, letterOfCreditID, EndUserID, LCNo, AmendType) VALUES (#" & Format(Date, "m\/d\/yyyy") & "#," & Me!ID & "," & Me!EndUserID & ",'" & HyperlinkPart(Me!LCNo, acDisplayText) & "' "    'NOT SURE WHAT I WOULD PUT HERE IF ANYTHING TO SET THE THE VALUE TO EQUAL "ISSUE" IN THE COMBO BOX. ON TBLAMENDHISTORY.
 
  End If
Comment
Watch Question
Retired IT Professional
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE