|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Did you add a reference to the MSComm object? AFAIK it's not included in Access VBA, but it is in VB6.
There are some 3rd party Com port controls available too, but I don't know of any free ones.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#17
|
|||
|
|||
|
Do you mean adding a Reference Object from the Access Reference Library?
If so which one? Can you explain a bit further? Thanks for your help |
|
#18
|
||||
|
||||
|
hi Jay,
add the Microsoft Comm Control 6.0 to the project.
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#19
|
|||
|
|||
|
Wow that was a task.....I could not find it in Access....went on line and found the MSComm32.ocx control and added it to my project. It took a bit but finally got it in there.
I then ran my code and had an issue because I was calling it MSComm1. I went to the properties and it was named MSComm6. I used that and a bunch of my coding problems vanished. Although the most important still exists. It is not grabbing the NMEA String. I am trying to push it to a msxbox and to a text box. I get the message "NO DEAL" I dont get the Message "ENTERING CASE STATEMENT" So this is telling me a few things, I think: 1. I am getting into the Case Statement 2. It is not finding $GPGGA so goes to the Case Else statement and returns in a msxbox "NO DEAL" Do you have any thoughts as to why its not grabbing the string. Is it perhaps reading the comm port and at that instance the GPGGA string is not there? THere are a bunch of Strigns beign passed to the port. Do I have to tell it to wait till the GPGGA strign appears? CODE: Option Compare Database Private Sub Form_Load() If (Not MSComm6.PortOpen) Then ' Buffer to hold input string Dim Instring As String ' Use COM1. MSComm6.CommPort = 1 ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm6.Settings = "9600,N,8,1" ' Tell the control to read entire buffer when Input is used. MSComm6.InputLen = 0 ' Open the port. MSComm6.PortOpen = True ' Send the attention command to the modem. MSComm6.Output = "AT" & vbCr ' Ensure that the modem responds with "OK". ' Wait for data to come back to the serial port. Buffer$ = Buffer$ & MSComm6.Input MsgBox "SMS Port Open", vbOKOnly, "Port State" Else MsgBox "SMS Port Already Open", vbOKOnly, "Port State" End If MsgBox "End Form Load" Call MSComm6_OnComm End Sub '________________________________________________ Private Sub MSComm6_OnComm() MsgBox "Enter Return Code" 'Attempting to Return a value from the port Select Case MSComm6.CommEvent Case "$GPGGA" MsgBox "ENTERING CASE STATEMENT" 'writing the return to the buffer variable from the Comm Port Buffer = MSComm6.Input If InStr(Buffer, "$GPGGA") > 0 Then ' Converting the return so I can read it MsgBox StrConv(Buffer, vbUnicode) TEXTBOX.Text = MSComm6.Input End If Case Else MsgBox "NO DEAL" End Select End Sub |
|
#20
|
|||
|
|||
|
ALRIGHT HERES THE DEAL: I got it to start returning NMEA Strings....For some reason its returning all of them.....and on top of that I placed the code in the "Case Else". I dont know why the Case "$GPGGA" is not working....
What I am looking for is how to Buffer the numerous strings down to just the $GPGGA strings and then further by the newest $GPGGA string. ANY THOUGHTS? Private Sub MSComm6_OnComm() MsgBox "Enter Return Code" 'Attempting to Return a value from the port Select Case MSComm6.CommEvent Case "$GPGGA" MsgBox "ENTERING CASE STATEMENT" 'writing the return to the buffer variable from the Comm Port Buffer = MSComm6.Input If InStr(Buffer, "$GPGGA") > 0 Then ' Converting the return so I can read it MsgBox StrConv(Buffer, vbUnicode) TEXTBOX.Text = MSComm6.Input End If Case Else Dim NMEAString As String NMEAString = MSComm6.Input If InStr(NMEAString, "$GPGGA") > 0 Then ' Converting the return so I can read it MsgBox NMEAString 'MsgBox StrConv(NMEAString, vbUnicode) 'TEXTBOX.Text = NMEAString 'MsgBox "NO DEAL" End If End Select End Sub |
|
#21
|
||||
|
||||
|
Hi Jay,
you are mixing the string up with the event, you have to use the event in the case function and then only check for the input string. try using this: Code:
Select Case MSComm6.CommEvent
Case comEvReceive
Buffer = MSComm6.Input
If InStr(Buffer, "$GPGGA") > 0 Then 'check to see if the command has $GPGGA in front
TEXTBOX.Text = strConv(Buffer, vbUnicode)
End If
Case Else
MsgBox "NO DEAL"
End Select
hope this helps |
|
#22
|
|||
|
|||
|
To Make things easier I placed all the code under an OnClick button. I can do this right? I wrote a bit of code IN BLUE to try adn figure this out.
If I run the code with the Blue active and the Red commented out I get a return of all teh strings. If I run the code with the Blue commented out and the Red active it passes the first case statement and give me a message box NO DEAL. I am confused here....For some reason it cannot find the String $GPGGA...ALSO below is the Message beign sent to the Text Box.... I thank you so much for your help here....I am really confused why I cannot filter down teh string/message. CODE: Option Compare Database Private Sub Command8_Click() MSComm6.InBufferCount = 0 'Flush the Comm Port If (Not MSComm6.PortOpen) Then Dim Instring As String MSComm6.CommPort = 1 MSComm6.Settings = "9600,N,8,1" MSComm6.InputLen = 0 MSComm6.PortOpen = True MSComm6.Output = "AT" & vbCr ' Ensure that the modem responds with "OK". Buffer$ = Buffer$ & MSComm6.Input MsgBox "SMS Port Open", vbOKOnly, "Port State" Else MsgBox "SMS Port Already Open", vbOKOnly, "Port State" End If ' Dim NMEAString1 As String ' Forms!GPS_RETRIEVE!TEXTBOX.SetFocus 'MSComm6.InBufferCount = 0 ' NMEAString1 = MSComm6.Input ' If InStr(NMEAString1, "$GPGGA") > 0 Then ' ' Converting the return so I can read it ' TEXTBOX.Text = NMEAString1 ' End If Select Case MSComm6.CommEvent Case comEvReceive Buffer = MSComm6.Input If InStr(Buffer, "$GPGGA") > 0 Then 'See if it has GPGGA in front TEXTBOX.Text = StrConv(Buffer, vbUnicode) 'MsgBox StrConv(Buffer, vbUnicode) End If Case Else MsgBox "NO DEAL" End Select End Sub NMEA STRING/MESSAGE $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,3,1,10,01,09,235,00,03,14,262,00,05,00,114, 00,09,44,075,00*7C $GPGSV,3,2,10,14,43,239,00,15,58,179,00,18,59,082, 00,19,19,294,00*75 $GPGSV,3,3,10,21,24,157,00,22,74,329,00,,,,,,,,*75 $PGRME,,M,,M,,M*00 $GPGLL,,,,,132526,*51 $PGRMZ,,,*7E $PGRMM,NAD83*29 $GPBOD,,T,,M,,*47 $GPRTE,1,1,c,0*07 $GPRMC,132527,V,,,,,,,260805,,*38 $GPRMB,V,,,,,,,,,,,,V*66 $GPGGA,132527,,,,,0,00,,,M,,M,,*66 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,3,1,10,01,09,235,00,03,14,262,00,05,00,114, 00,09,44,075,00*7C $GPGSV,3,2,10,14,43,239,00,15,58,179,00,18,59,082, 00,19,19,294,00*75 $GPGSV,3,3,10,21,24,157,00,22,74,329,00, |
|
#23
|
|||
|
|||
|
Was looking further at my code and it appears that the
Case comEvReceive = 2 .....Does that mean its pinting to Com Port 2? THerefore I would not see the String.....Does that make sence? |
|
#24
|
||||
|
||||
|
Hi,
the code in red needs to be in the onComm event, because that will get triggered when a input from the unit comes through. the on_click will just get everything lying in the buffer of the unit that is why you are getting all the values. leave all the code as you have it, remove the red part and put it in the onComm event. Then click on the button so that the port is opened, and then send something to the unit and see if the onComm fires also change the code in red slightly, so that you can see if it goes into the select, try this in the oncomm event Code:
Select Case MSComm6.CommEvent Case comEvReceive msgbox "Input Received" Buffer = MSComm6.Input If InStr(Buffer, "$GPGGA") > 0 Then 'See if it has GPGGA in front TEXTBOX.Text = StrConv(Buffer, vbUnicode) 'MsgBox StrConv(Buffer, vbUnicode) End If Case Else MsgBox "NO DEAL" End Select hope this helps |
|
#25
|
|||
|
|||
|
NoFriends....I THANK YOU SO MUCH FOR YOUR HELP HERE......
This is really driving me crazy here....THis is exacty what I have....and for some reason it will not go into the first Case Statement. It does not return the message box "Input Received". Although it does return the NO DEAL message which is in the Case Else Statement...So that tells me it is not seeing the $GPGGS statement. But i know its there. I can return the message with the Blue Code below. I am not running into an issue because I am calling the OnComm event am I? "Call MSComm6_OnComm" Option Compare Database Private Sub Command8_Click() If (Not MSComm6.PortOpen) Then Dim Instring As String MSComm6.CommPort = 1 MSComm6.Settings = "9600,N,8,1" MSComm6.InputLen = 0 MSComm6.PortOpen = True MSComm6.Output = "AT" & vbCr ' Ensure that the modem responds with "OK". Buffer$ = Buffer$ & MSComm6.Input MsgBox "SMS Port Open", vbOKOnly, "Port State" Else MsgBox "SMS Port Already Open", vbOKOnly, "Port State" End If MsgBox "End OnClick Load" Call MSComm6_OnComm End Sub Public Sub MSComm6_OnComm() Select Case MSComm6.CommEvent Case comEvReceive MsgBox "Input Received" Buffer = MSComm6.Input If InStr(Buffer, "$GPGGA") > 0 Then 'See if it has GPGGA in front TEXTBOX.Text = StrConv(Buffer, vbUnicode) MsgBox StrConv(Buffer, vbUnicode) End If Case Else MsgBox "NO DEAL" End Select End Sub OTHER CODE: ' Dim NMEAString1 As String ' Forms!GPS_RETRIEVE!TEXTBOX.SetFocus 'MSComm6.InBufferCount = 0 ' NMEAString1 = MSComm6.Input ' If InStr(NMEAString1, "$GPGGA") > 0 Then ' ' Converting the return so I can read it ' TEXTBOX.Text = NMEAString1 ' End If |
|
#26
|
|||
|
|||
|
I took the Call to the CommEvent out and It still gives me the NO DEAL message box. Which tells me it got into the Select statement but it went to the second case statement bypassing the first....it dosent even get into the first....because the MsgBox "Input Received" is not being returned....
I am dumbfounded here....I thank you all for your help....As I am new to this......but excited because I am learngin a lot here..... |
|
#27
|
|||
|
|||
|
When I debug my code I see that the
Case comEvReceive = 2 what does that mean? |
|
#28
|
|
|