Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

message box results

Discussion in 'Information Technology' started by Wendy, Jul 28, 2006.

  1. Wendy

    Wendy
    Expand Collapse
    Guest

    Hi

    I'm new to the vb side of access and would like to get a message box to
    display the results of a query (or query turned into sql) whilst the user is
    running a macro with the option for them to cancel out of the macro if the
    displayed results are not correct. I'm having trouble getting the
    messagebox to act on the sql code, all I can make it do is display the code.
    What am I doing wrong please? This is my code.

    Wendy

    Sub Bankline()
    Dim strMsg, myTitle, sqlstring, style
    style = vbOKCancel
    sqlstring = "SELECT bank.TRANSDATE, bank.AMOUNT, bank.DETAILS,
    bank.TRANSCODE,bank.CHEQUENO WHERE (([bank].[TRANSCODE]) Not Like 'CC' And
    Not Like 'MSC' And Not Like 'CHG'))"

    myTitle = "MsgBox bank Records" ' Define title.
    msgbox "The first record in the file is " & sqlstring & vbOKCancel

    If Response = vbCancel Then End

    End Sub
     
  2. Loading...

    Similar Threads Forum Date
    How message of love from Sikh gurus are helping Pakistani Christians to fight forced conversions Sikh Sikhi Sikhism Oct 12, 2015
    Messages from God Sikh Sikhi Sikhism Aug 23, 2015
    Message of Guru Granth Sahib Essays on Sikhism Jan 30, 2014
    World U.N. chief's message to North Korean leader Breaking News Apr 12, 2013
    Christianity Pope Francis prays for world peace in Easter Sunday message Interfaith Dialogues Apr 1, 2013

  3. Norman Yuan

    Norman Yuan
    Expand Collapse
    Guest

    Sub xxxxx()

    If MsgBox("This is the question." & vbcr & vbcr & "Do you want to
    continue?",myTitle,vbInformation+style)=vbCancel Then Exit Sub

    End Sub

    DO NOT (or NEVER) use "END" ( as your code "If Response = vbCancel Then
    End" ) in VBA code.


    "Wendy" <Wendy @sunnygirl.com> wrote in message
    news:GOudnV5hE5lJJxPZRVnygw@bt.com...
    > Hi
    >
    > I'm new to the vb side of access and would like to get a message box to
    > display the results of a query (or query turned into sql) whilst the user
    > is
    > running a macro with the option for them to cancel out of the macro if the
    > displayed results are not correct. I'm having trouble getting the
    > messagebox to act on the sql code, all I can make it do is display the
    > code.
    > What am I doing wrong please? This is my code.
    >
    > Wendy
    >
    > Sub Bankline()
    > Dim strMsg, myTitle, sqlstring, style
    > style = vbOKCancel
    > sqlstring = "SELECT bank.TRANSDATE, bank.AMOUNT, bank.DETAILS,
    > bank.TRANSCODE,bank.CHEQUENO WHERE (([bank].[TRANSCODE]) Not Like 'CC' And
    > Not Like 'MSC' And Not Like 'CHG'))"
    >
    > myTitle = "MsgBox bank Records" ' Define title.
    > msgbox "The first record in the file is " & sqlstring & vbOKCancel
    >
    > If Response = vbCancel Then End
    >
    > End Sub
    >
    >
     
  4. Wendy

    Wendy
    Expand Collapse
    Guest

    OK thanks for that, as I said I'm new to vb code. Am I doing something else
    wrong because that still doesn't make vb process my sqlstring and show the
    data in the messagebox?

    Thanks

    Wendy

    "Norman Yuan" <NotReal@NotReal.not> wrote in message
    news:u7l9lRvjGHA.4816@TK2MSFTNGP04.phx.gbl...
    > Sub xxxxx()
    >
    > If MsgBox("This is the question." & vbcr & vbcr & "Do you want to
    > continue?",myTitle,vbInformation+style)=vbCancel Then Exit Sub
    >
    > End Sub
    >
    > DO NOT (or NEVER) use "END" ( as your code "If Response = vbCancel Then
    > End" ) in VBA code.
    >
    >
    > "Wendy" <Wendy @sunnygirl.com> wrote in message
    > news:GOudnV5hE5lJJxPZRVnygw@bt.com...
    > > Hi
    > >
    > > I'm new to the vb side of access and would like to get a message box to
    > > display the results of a query (or query turned into sql) whilst the

    user
    > > is
    > > running a macro with the option for them to cancel out of the macro if

    the
    > > displayed results are not correct. I'm having trouble getting the
    > > messagebox to act on the sql code, all I can make it do is display the
    > > code.
    > > What am I doing wrong please? This is my code.
    > >
    > > Wendy
    > >
    > > Sub Bankline()
    > > Dim strMsg, myTitle, sqlstring, style
    > > style = vbOKCancel
    > > sqlstring = "SELECT bank.TRANSDATE, bank.AMOUNT, bank.DETAILS,
    > > bank.TRANSCODE,bank.CHEQUENO WHERE (([bank].[TRANSCODE]) Not Like 'CC'

    And
    > > Not Like 'MSC' And Not Like 'CHG'))"
    > >
    > > myTitle = "MsgBox bank Records" ' Define title.
    > > msgbox "The first record in the file is " & sqlstring & vbOKCancel
    > >
    > > If Response = vbCancel Then End
    > >
    > > End Sub
    > >
    > >

    >
    >
     

Share This Page