增加MS Access表问题的计数器 [英] Increment Counter of MS Access Table issue

查看:59
本文介绍了增加MS Access表问题的计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在MS Acess环境中使用VB增加表中的计数器时遇到问题。下面提到的是一个实例。


实现逻辑


表字段

Serialno = pk数据类型文本

StudentId文字

课程文字

主题文字

入学编号


设计查看

组合框(无界) - 定义列表(S1,S2,S3,S4,S5)

Textbox1 - ControlSource StudentId

TextBox2 - ControlSource课程

TextBox3 - ControlSource主题

TextBox4 - ControlSource Intake


逻辑

Serialno StudentId

1 S1

2 S2

3 S3

4 S4

5 S5

6 S6(新记录)


当用户从combox中选择值时,它将在表格的文本框中列出相应的值。


但我需要的是选择相同的值,比如说s1和位于表格的第6行,并将计数器增加1,这意味着SerialNo将显示6表。


另外,我需要检查字段的记录并确保在插入之前它是空的,而不是覆盖现有的当前记录,但是将新记录附加到字段为空的recordSet的下一行。


我知道rs.MoveFirst是移动到第一列而rs.MoveNext是移动到下一条记录但是太确定了至于hw迭代recordSet以在插入之前检查空字段值。我是否使用DLookup或循环播放?另外,


有没有人知道这可以用RecordSet属性实现吗?

rs.MoveFirst,rs.MoveNext,rs.AddNew或sql insert query 。我是否为此实现使用AddRecord或save操作?我还需要过滤StudentId的重复值,这意味着值只显示一次。


任何指导,代码片段,逻辑都将非常受欢迎。

Hi guys,

I have an issue with incrementing a counter in a table using VB in MS Acess environment. Below mentioned is an instance.

Implementation logic

Table fields
Serialno = pk Datatype text
StudentId Text
Course Text
Subject Text
Intake Number

Design View
Combo box (Unbounded) - defined list (S1, S2, S3, S4, S5)
Textbox1 - ControlSource StudentId
TextBox2 - ControlSource Course
TextBox3 - ControlSource Subject
TextBox4 - ControlSource Intake

Logic
Serialno StudentId
1 S1
2 S2
3 S3
4 S4
5 S5
6 S6 (new record)

When user select the values from the combox, it will list the corresponding values in the textboxes of the table.

But what I need is to select the same value like say s1 and position at the 6 row of the table and increment the counter by 1, which meant that SerialNo will show six in the table.

In addition, I need to check the record of the field and make sure it is empty before the insertion and not overwritting the existing the current record but append the new record to the next row of the recordSet where the fields is empty.

I do knw that rs.MoveFirst is to move to the first column and rs.MoveNext is move to next record but nt too sure as to hw to iterate the recordSet to check for null fields values before insertion. Do I use DLookup or loop through the field? In addition,

Does anyone knw hw can this be achieved using RecordSet properties?
rs.MoveFirst, rs.MoveNext, rs.AddNew or sql insert query. Do I use AddRecord or save operation for this implementation? I also need to filter duplicate values of the StudentId mean the values only show once.

Any guidance, code snippets, logic will be very much appreciated.

推荐答案


大家好,


我在使用VB增加表中的计数器时遇到问题MS Acess环境。下面提到的是一个实例。


实现逻辑


表字段

Serialno = pk数据类型文本

StudentId文字

课程文字

主题文字

入学编号


设计查看

组合框(无界) - 定义列表(S1,S2,S3,S4,S5)

Textbox1 - ControlSource StudentId

TextBox2 - ControlSource课程

TextBox3 - ControlSource主题

TextBox4 - ControlSource Intake


逻辑

Serialno StudentId

1 S1

2 S2

3 S3

4 S4

5 S5

6 S6(新记录)


当用户从combox中选择值时,它将在表格的文本框中列出相应的值。
< ----------------- ^^^^非常清楚^^^^ vvvv不清楚vvvv

但是什么我需要的是选择相同的值,比如说s1和位于表格的第6行并增加将计数器加1,这意味着SerialNo将在表格中显示六个。


此外,我需要检查字段的记录并确保在插入之前它是空的并且不会覆盖现有的当前记录,而是将新记录追加到recordSet的下一行,其中字段为空。


我知道rs.MoveFirst是移动到第一列和rs.MoveNext移动到下一条记录,但是不能确保在插入之前迭代recordSet以检查空字段值。我是否使用DLookup或循环播放?另外,


有没有人知道这可以用RecordSet属性实现吗?

rs.MoveFirst,rs.MoveNext,rs.AddNew或sql insert query 。我是否为此实现使用AddRecord或save操作?我还需要过滤StudentId的重复值,这意味着值只显示一次。


任何指导,代码片段,逻辑将非常感激。
Hi guys,

I have an issue with incrementing a counter in a table using VB in MS Acess environment. Below mentioned is an instance.

Implementation logic

Table fields
Serialno = pk Datatype text
StudentId Text
Course Text
Subject Text
Intake Number

Design View
Combo box (Unbounded) - defined list (S1, S2, S3, S4, S5)
Textbox1 - ControlSource StudentId
TextBox2 - ControlSource Course
TextBox3 - ControlSource Subject
TextBox4 - ControlSource Intake

Logic
Serialno StudentId
1 S1
2 S2
3 S3
4 S4
5 S5
6 S6 (new record)

When user select the values from the combox, it will list the corresponding values in the textboxes of the table.
<----------------- ^^^^ Very Clear ^^^^ vvvv Unclear vvvv
But what I need is to select the same value like say s1 and position at the 6 row of the table and increment the counter by 1, which meant that SerialNo will show six in the table.

In addition, I need to check the record of the field and make sure it is empty before the insertion and not overwritting the existing the current record but append the new record to the next row of the recordSet where the fields is empty.

I do knw that rs.MoveFirst is to move to the first column and rs.MoveNext is move to next record but nt too sure as to hw to iterate the recordSet to check for null fields values before insertion. Do I use DLookup or loop through the field? In addition,

Does anyone knw hw can this be achieved using RecordSet properties?
rs.MoveFirst, rs.MoveNext, rs.AddNew or sql insert query. Do I use AddRecord or save operation for this implementation? I also need to filter duplicate values of the StudentId mean the values only show once.

Any guidance, code snippets, logic will be very much appreciated.



箭头一切都很完美,并且得到了很好的解释。不幸的是,从那时起我迷路了,真的不确定你在寻找什么。有没有机会从那一点重做?

Up to the arrow everything made perfect sense and was well explained. Unfortunately, from that point I got lost and was really unsure of what you were looking for. Any chance of redoing from that point?


你好技术


我知道你提出了一个非常详细的问题,但我真的不喜欢了解你想要什么。你能尝试改写一下你的主要问题吗?


Mary
Hi techno

I know you''ve given a very detailed question but I really don''t understand what you want. Can you try rephrasing your main question?

Mary


你好mmccarthy,


谢谢你亲切的回应。


我需要的是能够在迭代记录集时递增计数器。由于我的表由预定义的值组成,所以我希望它以我能够将记录追加到表的最后一个直接记录的方式执行。


例如,StudentID(S1-S5)因此我想将下一条记录附加到表中,而不会覆盖所有先前的条目(S1-S5)。将recordSet移动到表的最后一条记录并插入值。


BTw,我尝试使用循环迭代记录字段以测试/单步执行错误/目的,但在移动到下一条记录时遇到错误。任何想法都可以解决吗?我为我的字段设置了一个变量。


Dim fld为DAO.Field


错误消息:

fld.Value< object variable or with阻止变量未设置>


这是一种方式,我只是循环通过表的记录/行而不访问单个字段/列?


RecordSet迭代


rs.MoveFirst - 第一条记录

rs.MoveNext - 下一条记录

rs.Movelastt - 最后记录

Hi mmccarthy,

thanks for yr kind response.

what i need is to be able to increment the counter when iterating through the recordset. As my table consists of pre-defined values so i want it to perform in the way whereby i am able to append the record to the last immediate record of the table.

For instance, StudentID (S1-S5) so i want to append the next record to the table without overwritting all the previous entry (S1-S5). move the recordSet to the last record of the table and insert the values.

BTw, I tried using a loop to iterate through the field of the record for testing / stepping through for errors / purposes but encountering an error when i move to the next record. Any idea hw can that be resolved? I have set a variable for my field.

Dim fld as DAO.Field

Error msg:
fld.Value <object variable or with block variablel not set>

Is that a way wherby i just loop through the record / row of the table without accesing the individual field / column?

RecordSet iteration

rs.MoveFirst - first record
rs.MoveNext - Next record
rs.Movelastt - Last record


你好技术


我知道你提出了一个非常详细的问题,但我真的不喜欢不明白你想要什么。你能试着改写一下你的主要问题吗?


Mary
Hi techno

I know you''ve given a very detailed question but I really don''t understand what you want. Can you try rephrasing your main question?

Mary


这篇关于增加MS Access表问题的计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆