Home > Software engineering >  Add records to the vb
Add records to the vb

Time:09-26

 If MsgBox (" save the record?" , vbOKCancel, "notice")=vbNo Then 
The Exit Sub
The Else
Query_max_fiberno (CFiber_No)
Rs. AddNew
Data_to_DB
Rs. Update
Query_CFiber_No (Trim (Text9))
If Not (rs1. EOF And rs1. BOF) Then
MsgBox Text9 & amp; (" successfully saved!" ), 48, "note"
End the If
Text9. SetFocus
End the If


Code as above, the question now is whether the program execution to query_max_fiberno (CFiber_No) this stopped, also do not complain,
Query_max_fiberno (CFiber_No) code is as follows:
 Public Sub query_max_fiberno (CFiber_No) 
Strsql="select Max (cfiber_no, 9) (right) from coloring_product"
The Set QY=cn. CreateQuery (" ", Strsql)
'the QY. RdoParameters (0)=Trim (Text9. Text)
The Set rs2=QY. OpenResultset (rdOpenForwardOnly rdConcurReadOnly)
While Not rs2. EOF
If Label3 (11). The Caption="850 nm" Then
Text9="JBM" & amp; (Val (rs2 (0)) + 1) & amp; "
"The Else
Text9="JBS" & amp; (Val (rs2 (0)) + 1) & amp; "
"End the If
The Exit Sub
Rs2. MoveNext
Wend

End Sub


I ask, where is the problem really out, thank you!

CodePudding user response:

Use the remote database? Slow response is normal,
You cn. QueryTimeout set to?

CodePudding user response:

reference 1st floor Tiger_Zhao response:
using the remote database? Slow response is normal,
You cn. QueryTimeout set to?


It is not slow but there is no next move but no error
Thank you please guide me I am a rookie!

CodePudding user response:

Don't pull! Answer the question!

CodePudding user response:

Then tracking, in inside query_max_fiberno function set breakpoints, continue to step tracking

CodePudding user response:

reference Tiger_Zhao reply: 3/f
don't pull! Answer the question!

Is not a remote database is not set the Timeout

CodePudding user response:

First, identify the SQL directly in the database is "soon",
Second, continue to step through within the function, perform "stopped" until what?
In the end, you this query returns number of records?
You do the systemic circulation, but real only last one data assigned to the Text9, in front of the assignment are covered,
Why not use the SELECT TOP 1... The ORDER BY... DESC directly take the last one,

CodePudding user response:

refer to 6th floor Tiger_Zhao response:
first, confirm SQL directly in the database performance is "soon",
Second, continue to step through within the function, perform "stopped" until what?
In the end, you this query returns number of records?
You do the systemic circulation, but real only last one data assigned to the Text9, in front of the assignment are covered,
Why not use the SELECT TOP 1... The ORDER BY... DESC directly take the last one,


I'm sorry! May I describe a bit of a problem, in fact query_max_fiberno this step is success has been assigned to TEXT9,
The question now is:
Rs. AddNew
Data_to_DB
Rs. Update
Save the data did not succeed,

Data_to_DB code is as follows:
 Public Sub Data_to_DB () 
If Val (Text1) & gt; 0 Then
Rs (" work_No ")=Text1. Text
End the If
If Val (Combo1) & gt; 0 Then
Rs (" Chief_Opr ")=Combo1. Text
End the If
If Len (Text9) & gt; 10 Then
Rs (" CFIBER_NO ")=Text9. Text
End the If
If Len (Combo2) & gt; 0 Then
Rs (" Shift_No ")=Combo2. Text
End the If
If Len (Combo3) & gt; 0 Then
Rs (" Shift ")=Combo3. Text
End the If
If Len (Text2) & gt; 8 Then=
Rs (" Cdate ")=Now ()
End the If
If Len (Combo4)=4 Then
Rs (" Equip_No ")=Combo4. Text
End the If
If Len (Text3 (0)) & gt; 1 Then
Rs (" Fiber_No ")=Text3 (0). The Text
End the If
If Len (Combo6) & gt; 1 Then
Rs (" JOB_TYPE ")=Combo6. Text
End the If
If Len (Combo5 (1)) & gt; 0 Then
Rs (" Contract_No ")=Trim (Combo5 (1). The Text)
End the If
If Len (Combo5 (0)) & gt; 0 Then
Rs (" Production_Type ")=Trim (Combo5 (0). The Text)
End the If
'If Val (. Combo5 (5)) & gt;=0 Then
'the rs (" MAC ")=Val (. Combo5 (5))
'End If
If Len (Combo5 (3)) & gt; 0 Then
Rs (" Fiber_Coloring ")=Trim (Combo5 (3). The Text)
End the If
If Len (Combo5 (2)) & gt; 0 Then
Rs (" Cable_Type ")=Trim (Combo5 (2). The Text)
End the If
If Len (Combo5 (4)) & gt; 0 Then
Rs (" Fiber_Source ")=Trim (Combo5 (4). The Text)
End the If
If Val (Text3 (3)) & gt; 0 Then
Rs (" Fiber_Len ")=Format (Val (Text3 (3). The Text), "#. # # #")
End the If
'If Val (. Text3 (13)) & gt; 0 Then
Rs (" max_cld_dia ")=Format (Val (Text3 (13). The Text), "#. # # #")
'End If
The Select Case UCase (Left (Combo5 (4), 2))
Case "Y5 Y6", ""," Y7 ", "Y8", "Y9", "YA" and "YB", "YC", "YD", "YE", "YF
"If Val (Text3 (4)) & gt; 0 Then
Rs (" A_850 ")=Format (Val (Text3 (4). The Text), "#. # # #")
End the If
If Val (Text3 (5)) & gt; 0 Then
Rs (" A_1300 ")=Format (Val (Text3 (5). The Text), "#. # # #")
End the If
If Val (Text3 (6)) & gt; 0 Then
Rs (" B_850 ")=Format (Val (Text3 (6). The Text), "# # #")
End the If
If Val (Text3 (7)) & gt; 0 Then
Rs (" B_1300 ")=Format (Val (Text3 (7). The Text), "# # #")
End the If
In Case the Else
Rs (" Coef_PMD ")=Format (Val (Text3 (8). The Text), "#. # # #")
If Val (Text3 (4)) & gt; 0 Then
Rs (" A_1310 ")=Format (Val (Text3 (4). The Text), "#. # # #")
End the If
If Val (Text3 (5)) & gt; 0 Then
Rs (" A_1550 ")=Format (Val (Text3 (5). The Text), "#. # # #")
End the If
End the Select
If Len (Text3 (9)) & gt; 1 Then
Rs (" reject_reason ")=Trim (Text3 (9). The Text)
End the If
'If Len (. Text3 (10)) & gt; 1 Then
'the rs (" reject_code ")=Val (. Text3 (10))
'End If
If Len (Combo5 (6)) & gt; 1 Then
Rs (" job_no ")=Combo5 (6). The Text
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related