|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#46
|
|||
|
|||
|
NoFriends - I thank you sdo much fro your help....it is very appreciated. As for the strign not showing up complete you have got me. I cannot get it to work.
I push the return to the Text Box and I only get "$". I push the return to a message box and I get "$GPGGA," I use the delay and the message box and I get multiple strign returned. I get "GPGLL", "GPGGA", "GSVRV" etc. It seems that when I use the delay It stops filotering out the "GPGGA" string I am looking for....... Do you knkow of any other ideas I should research as to why it is not grabbing the particular string I am after? Thanks Again...... |
|
#47
|
||||
|
||||
|
Hi Jay,
I am at a loss at the moment ![]() I would suggest to research how your specific unit send through the data to the comm port, it my instance, it was only a one line input string, and only one at a time, maybe your unit handles it a bit differently?
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#48
|
||||
|
||||
|
Hi Jay,
thanx for the comments ![]() I am a he if you were wondering ![]() How is it going with the application? |
|
#49
|
|||
|
|||
|
Going well.....I have accomplished most of what I set out to do:
Push the NMEA String to the Comm Port. In Access, write some code that will read the Comm Port Grab the NMEA String Split it apart by commas Write each to a variable Show said variables in Text Boxes. Thats 90% of what I set out to do. I have an Access db with a Form in it. It has a ton of Input Boxes that are collecting various data. I am now attampting to join the two applications, in such, adding the GPS coordinates to the database for location inside a GIS Application. Currently I am not concerned with combining the two applications. I am just trying to get the variables to write to a table in the database rather than the TextBoxes. I know this involves taking a different angle am I am researching that now. I think I have to write some code to connect to the specific table then push the specific variable to that field? Something along these lines: Dim rs As DAO.Recordset Set rs = Me.Recordset Think this gets me into the recordset but dont know how to specify the table? Nor right each specific variable to the table in that record..... The Me. terminology is a bit confusing the me Dont mean to bother you but if have any suggestions please feel free.....again thank you for your help..... |
|
#50
|
|||
|
|||
|
FOR ANYONE READING THIS....HERE IS WHAT I HAVE SO FAR. ANY QUESTIONS PLEASE FEEL FREE TO ASK.....THIS IS ALL WORKING. I WILL BE ADDING TO THIS IN THE NEAR FURTURE AND WILL AGAIN POST MY CODE FOR ANYONE INTERESTED IN DOIGN THE SAME......
CODE: Option Compare Database Dim NMEAString As String Dim NMEAString2 As String Dim X As String Dim Y As String Dim LongHem As String Dim LatHem As String Dim Elev As String Dim ElevUnit As String Dim NewCoords As String Dim TEST As String '============================================= '============================================= Private Sub Command8_Click() MSComm6.InBufferCount = 0 'Flush the Buffer If (Not MSComm6.PortOpen) Then Dim Instring As String ' Buffer to hold input string MSComm6.CommPort = 1 ' Use COM1. MSComm6.Settings = "9600,N,8,1" ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm6.InputLen = 0 ' Tell the control to read entire buffer when Input is used. MSComm6.PortOpen = True ' Open the port. MSComm6.Output = "AT" & vbCr ' Send the attention command to the modem. Ensure that the modem responds with "OK". Buffer$ = Buffer$ & MSComm6.Input ' Wait for data to come back to the serial port. 'MsgBox "SMS Port Open", vbOKOnly, "Port State" Else MsgBox "SMS Port Already Open, It is now closing", vbOKOnly, "Port State" MSComm6.PortOpen = False End If End Sub '============================================= '============================================= Public Sub MSComm6_OnComm() Select Case MSComm6.CommEvent Case comEvReceive Dim Buffer As String 'These two lines allow the Buffer variable Forms!GPS_RETRIEVE!TEXTBOX.SetFocus 'to be passed into TextBox MSComm6.InputLen = 0 'Set Buffer to zero or delete all in buffer Call Wait(1, 1) Buffer = MSComm6.Input NMEAString = Buffer NMEAString2 = Buffer If InStr(Buffer, "$GPGGA") > 0 Then 'See if it has GPGGA in front TEXTBOX.Text = Buffer 'TEXTBOX.Text = StrConv(Buffer, vbUnicode) ' MsgBox Buffer 'MsgBox StrConv(Buffer, vbUnicode) MSComm6.PortOpen = False 'Close the Port End If Case Else MsgBox "No NMEA String Found" End Select End Sub '============================================= '============================================= Private Sub ClosePort_Click() If MSComm6.PortOpen Then MSComm6.PortOpen = False 'Close the Comm Port OnClick Else MsgBox "The Communications Port is closed" End If End Sub '============================================= '============================================= Public Sub GetString_Click() Dim s As String, sItems() As String Dim i As Integer Dim NMEA As String NMEA = NMEAString '''''''''''Sets the Variable from MSComm6 to NMEA sItems = Split(NMEA, ",") ''''''''''''This splits by a comma. Change if needed"," i = 0 For i = 0 To UBound(sItems) ''''''''''''Sets i to the Upper Bound of sItems or the NMEA String NewCoords = Trim(sItems(i)) ''''''''''''Trims the spaces on either side of the string If i = 2 Then '''''''''''''Looks for the 2nd word in the string X = NewCoords '''''''''''''Sets the 2nd word to the variable First1 ElseIf i = 3 Then LongHem = NewCoords ElseIf i = 4 Then Y = NewCoords ElseIf i = 5 Then LatHem = NewCoords ElseIf i = 9 Then Elev = NewCoords ElseIf i = 10 Then ElevUnit = NewCoords ElseIf i = 14 Then TEST = NewCoords End If Next 'Walks through the string 'MsgBox X 'Returns the variables in a message box 'MsgBox LongHem 'MsgBox Y 'MsgBox LatHem 'MsgBox Elev 'MsgBox ElevUnit Forms!GPS_RETRIEVE!txtXCoord.SetFocus 'to be passed into TextBox If X = "" Then txtXCoord.Text = "NO VALUE" Else txtXCoord.Text = X End If Forms!GPS_RETRIEVE!txtLongHem.SetFocus If LongHem = "" Then txtLongHem.Text = "NO VALUE" Else txtLongHem.Text = LongHem End If Forms!GPS_RETRIEVE!txtYCoord.SetFocus If Y = "" Then txtYCoord.Text = "NO VALUE" Else txtYCorrd.Text = Y End If Forms!GPS_RETRIEVE!txtLatHem.SetFocus If LatHem = "" Then txtLatHem.Text = "NO VALUE" Else txtLatHem.Text = LatHem End If Forms!GPS_RETRIEVE!txtElev.SetFocus If Elev = "" Then txtElev.Text = "NO VALUE" Else txtElev.Text = Elev End If Forms!GPS_RETRIEVE!txtElevUnit.SetFocus If ElevUnit = "" Then txtElevUnit.Text = "NO VALUE" Else txtElevUnit.Text = ElevUnit End If Forms!GPS_RETRIEVE!Text37.SetFocus If TEST = "" Then Text37.Text = "NO VALUE" Else Text37.Text = TEST End If 'If TEST <> "" Then 'MsgBox TEST 'End If 'txtXCoord.Text = Test 'Dim Count As Integer 'Dim rs As DAO.Recordset 'Set rs = Me.Recordset 'Count = rs.RecordCount 'MsgBox (Count & " records") End Sub '============================================== '============================================== Public Sub MSComm6_OnUnload() MSComm6.PortOpen = False 'Close the Comm Port upon closing of the form End Sub '============================================= '============================================= Function Wait(Delay As Integer, DispHrglass As Integer) ' This function creates a time delay you must use a call to run it Call Wait(2,1) Dim DelayEnd As Double DoCmd.Hourglass DispHourglass DelayEnd = DateAdd("s", Delay, Now) While DateDiff("s", Now, DelayEnd) > 0 Wend DoCmd.Hourglass False End Function |
|
#51
|
||||
|
||||
|
HI,
you can use the docmd.runsql command to insert the values into the database instead of the text fields ![]() Code:
strSQL = "insert into gpsTable (field1, field2) values(get these from the variables)" DoCmd.setWarnings False DoCmd.RunSQL strSQL DoCmd.setWarnings True hope this helps |
|
#52
|
|||
|
|||
|
Question:
For the sake of this email...when I say data text boxes I mean the multiple text boxes used for the data collection. These update the database. From App1 When I say XY text boxes I am refering to the app2 that I have been working on to grab the NMEA String NOTE: I brought the two apps together into one database. They work fine seperatly. I am now tryingto bridge the two... App 1 I have a bunch of text boxes that are set up in a form that eventually update a database. And as such each of the text boxes has its control source set up to point to the Field in the Table. App2 Now....I have a few other text boxes set up to grab the XY NMEA string that I have been working on. If I set the control source of the data text boxes (app1) to the value of the the XY text boxes (app2) I do get the value to populate the app1 text box. Great! But now the control source is not pointing to the field in teh table for update. It reads it but will not update it. Is there a way to push the value (from App2) to the text box (app1) while maintaining the link to the table. That is keep the control source (text box of app1) pointing to the Table and write additional code to push the valueof the variable the app1 text box Does any of that make sense? |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Coding String from Com Port into Access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|