Am very new to Autocad. I need help on how to refresh or reload an Autocad Drawing. The Autocad drawing displays or gets data from an Access database. I run a Macro once the drawing is opened whcih asks for a sheet number using a form. When the sheet number is provided the corresponding values are picked from Access database and displayed correctly. If i run the macro again, after providing a different sheet number the new data is not loaded or the Autocad drawing is not refreshed. Any help or suggestion will be highly appreciated.
Regards,
Charley
I use the following code on the form command button to get the sheet number
ThisDrawing.Input_mas_tag (txtMas_tag.Value)
Then i use the following function to retrieve the appropriate record from the database.
Public Sub Input_mas_tag(tmas_tag As String)
Dim acad_txt_ent As Object
Dim rec As Recordset
Dim st As String
Dim col As Integer, row As Integer, count As Integer
Dim main_values As Variant
UserForm1.Hide
st = "select * from TAG_MASTER where LPSN = " + Chr(34) + tmas_tag + Chr(34) + ";"
Set rec = db.OpenRecordset(st)
If rec.BOF = False Then
main_values = rec.GetRows(rec.RecordCount)
For Each acad_txt_ent In ThisDrawing.ModelSpace
If acad_txt_ent.EntityName = "AcDbText" Then
For count = 0 To UBound(main_values, 1) Step 1
If acad_txt_ent.TextString = rec.Fields(count).SourceField Then
If IsNull(main_values(count, 0)) = False Then
acad_txt_ent.TextString = main_values(count, 0)
Else
acad_txt_ent.TextString = "-"
End If
acad_txt_ent.Update
Exit For
End If
Next count
End If
Next
Else
MsgBox "no record found", vbOKOnly
End If
End Sub
The above codes are working correctly except that when i give the sheet number for the second time, the drawing is not refreshed.
Regards,
Charley
I use the following code on the form command button to get the sheet number
ThisDrawing.Input_mas_tag (txtMas_tag.Value)
Then i use the following function to retrieve the appropriate record from the database.
Public Sub Input_mas_tag(tmas_tag As String)
Dim acad_txt_ent As Object
Dim rec As Recordset
Dim st As String
Dim col As Integer, row As Integer, count As Integer
Dim main_values As Variant
UserForm1.Hide
st = "select * from TAG_MASTER where LPSN = " + Chr(34) + tmas_tag + Chr(34) + ";"
Set rec = db.OpenRecordset(st)
If rec.BOF = False Then
main_values = rec.GetRows(rec.RecordCount)
For Each acad_txt_ent In ThisDrawing.ModelSpace
If acad_txt_ent.EntityName = "AcDbText" Then
For count = 0 To UBound(main_values, 1) Step 1
If acad_txt_ent.TextString = rec.Fields(count).SourceField Then
If IsNull(main_values(count, 0)) = False Then
acad_txt_ent.TextString = main_values(count, 0)
Else
acad_txt_ent.TextString = "-"
End If
acad_txt_ent.Update
Exit For
End If
Next count
End If
Next
Else
MsgBox "no record found", vbOKOnly
End If
End Sub
The above codes are working correctly except that when i give the sheet number for the second time, the drawing is not refreshed.