Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
j.romo
833 Views, 6 Replies

Ilogic MS Access find next empty record and record new record

Hello

Been using excel Spreadsheets to collect model information and ran into some issues with users trying to open the same Spreadsheet at the same time and giving us some headaches.

Now we are trying to go further and use a database with MS access,

and as far as i vcould find information on this board the only thing I could do is read information from the Database

Now I want to add information from Ilogic to the database, but just cant find the next empty record to record on it the fields I need. Here is the code Im using.

SyntaxEditor Code Snippet

Sub Main()

	Dim Table1 As String = "CAD"
	Dim query As String = "SELECT * FROM " & Table1
	Dim MDBConnString_ As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\DESKTOP-VDT88EI\database\Ingenieria.accdb;Persist Security Info=False;"
	Dim ds As New DataSet
	Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_)
	cnn.Open()
	Dim cmd As New OleDbCommand(query, cnn)
	Dim da As New OleDbDataAdapter(cmd)
	da.Fill(ds, Table1)
	cnn.Close()
	Dim t1 As DataTable = ds.Tables(Table1)
	Dim row As DataRow
	Dim Item(2) As String
	'Dim oNAME As String
Dim OPROJ As String
Dim oCREAT As String
Dim oDAT As String
Dim oCOMENT As String
Dim oSTATUS As String
oNAME = MT_NAMING
OPROJ = iProperties.Value("Project", "Project")
oDAT = iProperties.Value("Project", "Creation Date")
oCREAT = ThisApplication.GeneralOptions.UserName
oCOMENT = DESCRIPCION
oSTATUS = STATUS_MASTER	


	For Each row In t1.Rows
		If row(1) = oNAME Then
		i = MessageBox.Show("This part Number is allready recorded", "CAD", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
ElseIf row(1) = "" Then
	i = MessageBox.Show("Testing empty record", "CAD", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
	row(1)=MT_NAMING

	End If
	
		
	Next
End Sub